3eaf3699ab05ebbce3c6393aadb8420e2935cfd8
[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 _0xa2b6=['client','http','redis','defaults','socket.io-emitter','request','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','error','code','message','catch','GetVoiceQueueReport','findAll','options','raw','where','include','map','model','attributes','VoiceQueueReport','create','body','then','CreateVoiceQueueReport','UpdateVoiceQueueReport','update','limit','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','jayson/promise'];(function(_0x5c8f68,_0x1c5b61){var _0x5aeeba=function(_0xcefdee){while(--_0xcefdee){_0x5c8f68['push'](_0x5c8f68['shift']());}};_0x5aeeba(++_0x1c5b61);}(_0xa2b6,0x13f));var _0x6a2b=function(_0x51d4c6,_0x48e45a){_0x51d4c6=_0x51d4c6-0x0;var _0x21bcec=_0xa2b6[_0x51d4c6];return _0x21bcec;};'use strict';var _=require(_0x6a2b('0x0'));var util=require(_0x6a2b('0x1'));var moment=require(_0x6a2b('0x2'));var BPromise=require(_0x6a2b('0x3'));var rs=require(_0x6a2b('0x4'));var fs=require('fs');var Redis=require(_0x6a2b('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x6a2b('0x6'))(_0x6a2b('0x7'));var config=require('../../config/environment');var jayson=require(_0x6a2b('0x8'));var client=jayson[_0x6a2b('0x9')][_0x6a2b('0xa')]({'port':0x232a});config[_0x6a2b('0xb')]=_[_0x6a2b('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x6a2b('0xd'))(new Redis(config[_0x6a2b('0xb')]));require('./voiceQueueReport.socket')['register'](socket);function respondWithRpcPromise(_0x3d9a27,_0x37453b,_0x11dbce){return new BPromise(function(_0x5934d3,_0x110e1e){return client[_0x6a2b('0xe')](_0x3d9a27,_0x11dbce)['then'](function(_0x16ddb5){logger[_0x6a2b('0xf')](_0x6a2b('0x10'),_0x37453b,_0x6a2b('0x11'));logger[_0x6a2b('0x12')]('VoiceQueueReport,\x20%s,\x20%s,\x20%s',_0x37453b,_0x6a2b('0x11'),JSON['stringify'](_0x16ddb5));if(_0x16ddb5[_0x6a2b('0x13')]){if(_0x16ddb5[_0x6a2b('0x13')][_0x6a2b('0x14')]===0x1f4){logger[_0x6a2b('0x13')](_0x6a2b('0x10'),_0x37453b,_0x16ddb5[_0x6a2b('0x13')][_0x6a2b('0x15')]);return _0x110e1e(_0x16ddb5[_0x6a2b('0x13')][_0x6a2b('0x15')]);}logger[_0x6a2b('0x13')](_0x6a2b('0x10'),_0x37453b,_0x16ddb5[_0x6a2b('0x13')][_0x6a2b('0x15')]);return _0x5934d3(_0x16ddb5[_0x6a2b('0x13')][_0x6a2b('0x15')]);}else{logger[_0x6a2b('0xf')](_0x6a2b('0x10'),_0x37453b,_0x6a2b('0x11'));_0x5934d3(_0x16ddb5['result'][_0x6a2b('0x15')]);}})[_0x6a2b('0x16')](function(_0x3b34f8){logger[_0x6a2b('0x13')](_0x6a2b('0x10'),_0x37453b,_0x3b34f8);_0x110e1e(_0x3b34f8);});});}exports[_0x6a2b('0x17')]=function(_0x2fe72c){var _0x5d9f6c=this;return new Promise(function(_0x5097be,_0x33e702){return db['VoiceQueueReport'][_0x6a2b('0x18')]({'raw':_0x2fe72c[_0x6a2b('0x19')]?_0x2fe72c['options'][_0x6a2b('0x1a')]===undefined?!![]:![]:!![],'where':_0x2fe72c[_0x6a2b('0x19')]?_0x2fe72c['options'][_0x6a2b('0x1b')]||null:null,'attributes':_0x2fe72c['options']?_0x2fe72c['options']['attributes']||null:null,'limit':_0x2fe72c[_0x6a2b('0x19')]?_0x2fe72c['options']['limit']||null:null,'include':_0x2fe72c[_0x6a2b('0x19')]?_0x2fe72c[_0x6a2b('0x19')][_0x6a2b('0x1c')]?_[_0x6a2b('0x1d')](_0x2fe72c[_0x6a2b('0x19')][_0x6a2b('0x1c')],function(_0x661c88){return{'model':db[_0x661c88[_0x6a2b('0x1e')]],'as':_0x661c88['as'],'attributes':_0x661c88['attributes'],'include':_0x661c88['include']?_['map'](_0x661c88[_0x6a2b('0x1c')],function(_0x1d8f9e){return{'model':db[_0x1d8f9e['model']],'as':_0x1d8f9e['as'],'attributes':_0x1d8f9e[_0x6a2b('0x1f')],'include':_0x1d8f9e[_0x6a2b('0x1c')]?_[_0x6a2b('0x1d')](_0x1d8f9e[_0x6a2b('0x1c')],function(_0x5f076b){return{'model':db[_0x5f076b[_0x6a2b('0x1e')]],'as':_0x5f076b['as'],'attributes':_0x5f076b[_0x6a2b('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x36fa13){logger[_0x6a2b('0xf')]('GetVoiceQueueReport',_0x2fe72c);logger[_0x6a2b('0x12')](_0x6a2b('0x17'),_0x2fe72c,JSON['stringify'](_0x36fa13));_0x5097be(_0x36fa13);})[_0x6a2b('0x16')](function(_0x5a1963){logger[_0x6a2b('0x13')]('GetVoiceQueueReport',_0x5a1963[_0x6a2b('0x15')],_0x2fe72c);_0x33e702(_0x5d9f6c['error'](0x1f4,_0x5a1963['message']));});});};exports['CreateVoiceQueueReport']=function(_0x2db590){var _0x333e33=this;return new Promise(function(_0x447ece,_0x5428ad){return db[_0x6a2b('0x20')][_0x6a2b('0x21')](_0x2db590[_0x6a2b('0x22')],{'raw':_0x2db590['options']?_0x2db590[_0x6a2b('0x19')][_0x6a2b('0x1a')]===undefined?!![]:![]:!![]})[_0x6a2b('0x23')](function(_0x252ed0){logger[_0x6a2b('0xf')](_0x6a2b('0x24'),_0x2db590);logger[_0x6a2b('0x12')](_0x6a2b('0x24'),_0x2db590,JSON['stringify'](_0x252ed0));_0x447ece(_0x252ed0);})[_0x6a2b('0x16')](function(_0x587f3c){logger[_0x6a2b('0x13')]('CreateVoiceQueueReport',_0x587f3c['message'],_0x2db590);_0x5428ad(_0x333e33['error'](0x1f4,_0x587f3c[_0x6a2b('0x15')]));});});};exports[_0x6a2b('0x25')]=function(_0xf36ad9){var _0x3f1eb8=this;return new Promise(function(_0x320320,_0x143a90){return db[_0x6a2b('0x20')][_0x6a2b('0x26')](_0xf36ad9[_0x6a2b('0x22')],{'raw':_0xf36ad9[_0x6a2b('0x19')]?_0xf36ad9[_0x6a2b('0x19')][_0x6a2b('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xf36ad9['options']?_0xf36ad9['options'][_0x6a2b('0x1b')]||null:null,'attributes':_0xf36ad9[_0x6a2b('0x19')]?_0xf36ad9[_0x6a2b('0x19')]['attributes']||null:null,'limit':_0xf36ad9['options']?_0xf36ad9[_0x6a2b('0x19')][_0x6a2b('0x27')]||null:null})['then'](function(_0x5c89ca){logger[_0x6a2b('0xf')](_0x6a2b('0x25'),_0xf36ad9);logger[_0x6a2b('0x12')](_0x6a2b('0x25'),_0xf36ad9,JSON[_0x6a2b('0x28')](_0x5c89ca));_0x320320(_0x5c89ca);})[_0x6a2b('0x16')](function(_0x2f7018){logger[_0x6a2b('0x13')]('UpdateVoiceQueueReport',_0x2f7018[_0x6a2b('0x15')],_0xf36ad9);_0x143a90(_0x3f1eb8[_0x6a2b('0x13')](0x1f4,_0x2f7018['message']));});});};