5775c3892bf4979e791ba4b5f6194be16b3dc2df
[motion2.git] / server / api / voiceQueueReport / voiceQueueReport.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xeb4a=['stringify','error','code','message','result','VoiceQueueReport','findAll','options','where','attributes','include','map','model','GetVoiceQueueReport','catch','CreateVoiceQueueReport','body','raw','UpdateVoiceQueueReport','update','limit','lodash','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','defaults','localhost','socket.io-emitter','./voiceQueueReport.socket','request','then','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xeb4a,0x198));var _0xaeb4=function(_0x10e6e9,_0x127cff){_0x10e6e9=_0x10e6e9-0x0;var _0x478a54=_0xeb4a[_0x10e6e9];return _0x478a54;};'use strict';var _=require(_0xaeb4('0x0'));var util=require('util');var moment=require(_0xaeb4('0x1'));var BPromise=require(_0xaeb4('0x2'));var rs=require(_0xaeb4('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xaeb4('0x4'))['db'];var utils=require(_0xaeb4('0x5'));var logger=require(_0xaeb4('0x6'))(_0xaeb4('0x7'));var config=require(_0xaeb4('0x8'));var jayson=require(_0xaeb4('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0xaeb4('0xa')]=_[_0xaeb4('0xb')](config['redis'],{'host':_0xaeb4('0xc'),'port':0x18eb});var socket=require(_0xaeb4('0xd'))(new Redis(config[_0xaeb4('0xa')]));require(_0xaeb4('0xe'))['register'](socket);function respondWithRpcPromise(_0x27aab3,_0x5438c3,_0x558fe0){return new BPromise(function(_0x3d7869,_0xbe8cad){return client[_0xaeb4('0xf')](_0x27aab3,_0x558fe0)[_0xaeb4('0x10')](function(_0x50e53d){logger[_0xaeb4('0x11')](_0xaeb4('0x12'),_0x5438c3,_0xaeb4('0x13'));logger[_0xaeb4('0x14')](_0xaeb4('0x15'),_0x5438c3,_0xaeb4('0x13'),JSON[_0xaeb4('0x16')](_0x50e53d));if(_0x50e53d[_0xaeb4('0x17')]){if(_0x50e53d[_0xaeb4('0x17')][_0xaeb4('0x18')]===0x1f4){logger['error'](_0xaeb4('0x12'),_0x5438c3,_0x50e53d[_0xaeb4('0x17')][_0xaeb4('0x19')]);return _0xbe8cad(_0x50e53d[_0xaeb4('0x17')]['message']);}logger['error'](_0xaeb4('0x12'),_0x5438c3,_0x50e53d[_0xaeb4('0x17')]['message']);return _0x3d7869(_0x50e53d[_0xaeb4('0x17')][_0xaeb4('0x19')]);}else{logger[_0xaeb4('0x11')](_0xaeb4('0x12'),_0x5438c3,_0xaeb4('0x13'));_0x3d7869(_0x50e53d[_0xaeb4('0x1a')][_0xaeb4('0x19')]);}})['catch'](function(_0x74af15){logger['error'](_0xaeb4('0x12'),_0x5438c3,_0x74af15);_0xbe8cad(_0x74af15);});});}exports['GetVoiceQueueReport']=function(_0x5bc89c){var _0x479ffa=this;return new Promise(function(_0x243359,_0x42dbe8){return db[_0xaeb4('0x1b')][_0xaeb4('0x1c')]({'raw':_0x5bc89c[_0xaeb4('0x1d')]?_0x5bc89c[_0xaeb4('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x5bc89c[_0xaeb4('0x1d')]?_0x5bc89c[_0xaeb4('0x1d')][_0xaeb4('0x1e')]||null:null,'attributes':_0x5bc89c['options']?_0x5bc89c[_0xaeb4('0x1d')][_0xaeb4('0x1f')]||null:null,'limit':_0x5bc89c['options']?_0x5bc89c[_0xaeb4('0x1d')]['limit']||null:null,'include':_0x5bc89c[_0xaeb4('0x1d')]?_0x5bc89c['options'][_0xaeb4('0x20')]?_[_0xaeb4('0x21')](_0x5bc89c[_0xaeb4('0x1d')][_0xaeb4('0x20')],function(_0x1d6b77){return{'model':db[_0x1d6b77[_0xaeb4('0x22')]],'as':_0x1d6b77['as'],'attributes':_0x1d6b77[_0xaeb4('0x1f')],'include':_0x1d6b77[_0xaeb4('0x20')]?_['map'](_0x1d6b77[_0xaeb4('0x20')],function(_0x198a9b){return{'model':db[_0x198a9b[_0xaeb4('0x22')]],'as':_0x198a9b['as'],'attributes':_0x198a9b[_0xaeb4('0x1f')],'include':_0x198a9b[_0xaeb4('0x20')]?_['map'](_0x198a9b['include'],function(_0x2ec5a3){return{'model':db[_0x2ec5a3['model']],'as':_0x2ec5a3['as'],'attributes':_0x2ec5a3[_0xaeb4('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xaeb4('0x10')](function(_0x279379){logger['info'](_0xaeb4('0x23'),_0x5bc89c);logger[_0xaeb4('0x14')]('GetVoiceQueueReport',_0x5bc89c,JSON['stringify'](_0x279379));_0x243359(_0x279379);})[_0xaeb4('0x24')](function(_0x404135){logger[_0xaeb4('0x17')](_0xaeb4('0x23'),_0x404135[_0xaeb4('0x19')],_0x5bc89c);_0x42dbe8(_0x479ffa[_0xaeb4('0x17')](0x1f4,_0x404135['message']));});});};exports[_0xaeb4('0x25')]=function(_0x5a900f){var _0x2b9a72=this;return new Promise(function(_0x480476,_0x2a2387){return db[_0xaeb4('0x1b')]['create'](_0x5a900f[_0xaeb4('0x26')],{'raw':_0x5a900f[_0xaeb4('0x1d')]?_0x5a900f[_0xaeb4('0x1d')][_0xaeb4('0x27')]===undefined?!![]:![]:!![]})[_0xaeb4('0x10')](function(_0x2c556c){logger[_0xaeb4('0x11')](_0xaeb4('0x25'),_0x5a900f);logger[_0xaeb4('0x14')](_0xaeb4('0x25'),_0x5a900f,JSON['stringify'](_0x2c556c));_0x480476(_0x2c556c);})['catch'](function(_0x15123d){logger[_0xaeb4('0x17')]('CreateVoiceQueueReport',_0x15123d[_0xaeb4('0x19')],_0x5a900f);_0x2a2387(_0x2b9a72[_0xaeb4('0x17')](0x1f4,_0x15123d[_0xaeb4('0x19')]));});});};exports[_0xaeb4('0x28')]=function(_0x483131){var _0x512ea6=this;return new Promise(function(_0x52976d,_0x159c97){return db[_0xaeb4('0x1b')][_0xaeb4('0x29')](_0x483131[_0xaeb4('0x26')],{'raw':_0x483131[_0xaeb4('0x1d')]?_0x483131[_0xaeb4('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x483131['options']?_0x483131['options'][_0xaeb4('0x1e')]||null:null,'attributes':_0x483131[_0xaeb4('0x1d')]?_0x483131[_0xaeb4('0x1d')][_0xaeb4('0x1f')]||null:null,'limit':_0x483131['options']?_0x483131[_0xaeb4('0x1d')][_0xaeb4('0x2a')]||null:null})[_0xaeb4('0x10')](function(_0x254791){logger['info'](_0xaeb4('0x28'),_0x483131);logger[_0xaeb4('0x14')](_0xaeb4('0x28'),_0x483131,JSON[_0xaeb4('0x16')](_0x254791));_0x52976d(_0x254791);})[_0xaeb4('0x24')](function(_0x183221){logger[_0xaeb4('0x17')](_0xaeb4('0x28'),_0x183221[_0xaeb4('0x19')],_0x483131);_0x159c97(_0x512ea6[_0xaeb4('0x17')](0x1f4,_0x183221['message']));});});};