69583fe98eb38bf3515f7f57ae4f2cd03478d81d
[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 _0xa972=['limit','map','model','include','attributes','then','GetVoiceQueueReport','CreateVoiceQueueReport','create','body','UpdateVoiceQueueReport','update','raw','lodash','util','bluebird','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./voiceQueueReport.socket','register','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','VoiceQueueReport','options','where'];(function(_0x64ba97,_0x2662d2){var _0x2d655b=function(_0x26719a){while(--_0x26719a){_0x64ba97['push'](_0x64ba97['shift']());}};_0x2d655b(++_0x2662d2);}(_0xa972,0x88));var _0x2a97=function(_0x5276c1,_0x971d74){_0x5276c1=_0x5276c1-0x0;var _0x3b6133=_0xa972[_0x5276c1];return _0x3b6133;};'use strict';var _=require(_0x2a97('0x0'));var util=require(_0x2a97('0x1'));var moment=require('moment');var BPromise=require(_0x2a97('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2a97('0x3'))['db'];var utils=require(_0x2a97('0x4'));var logger=require(_0x2a97('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0x2a97('0x6'));var client=jayson[_0x2a97('0x7')][_0x2a97('0x8')]({'port':0x232a});config[_0x2a97('0x9')]=_[_0x2a97('0xa')](config[_0x2a97('0x9')],{'host':_0x2a97('0xb'),'port':0x18eb});var socket=require(_0x2a97('0xc'))(new Redis(config[_0x2a97('0x9')]));require(_0x2a97('0xd'))[_0x2a97('0xe')](socket);function respondWithRpcPromise(_0x5a7548,_0x548c01,_0x3b1cda){return new BPromise(function(_0xdd34b,_0x37035b){return client['request'](_0x5a7548,_0x3b1cda)['then'](function(_0xd662c4){logger[_0x2a97('0xf')](_0x2a97('0x10'),_0x548c01,_0x2a97('0x11'));logger[_0x2a97('0x12')](_0x2a97('0x13'),_0x548c01,'request\x20sent',JSON[_0x2a97('0x14')](_0xd662c4));if(_0xd662c4[_0x2a97('0x15')]){if(_0xd662c4['error'][_0x2a97('0x16')]===0x1f4){logger['error'](_0x2a97('0x10'),_0x548c01,_0xd662c4[_0x2a97('0x15')][_0x2a97('0x17')]);return _0x37035b(_0xd662c4[_0x2a97('0x15')]['message']);}logger[_0x2a97('0x15')](_0x2a97('0x10'),_0x548c01,_0xd662c4['error']['message']);return _0xdd34b(_0xd662c4[_0x2a97('0x15')][_0x2a97('0x17')]);}else{logger[_0x2a97('0xf')]('VoiceQueueReport,\x20%s,\x20%s',_0x548c01,_0x2a97('0x11'));_0xdd34b(_0xd662c4['result'][_0x2a97('0x17')]);}})[_0x2a97('0x18')](function(_0x412b45){logger[_0x2a97('0x15')](_0x2a97('0x10'),_0x548c01,_0x412b45);_0x37035b(_0x412b45);});});}exports['GetVoiceQueueReport']=function(_0x2992b6){var _0x5d9b34=this;return new Promise(function(_0x245f6b,_0x52143b){return db[_0x2a97('0x19')]['findAll']({'raw':_0x2992b6[_0x2a97('0x1a')]?_0x2992b6[_0x2a97('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x2992b6[_0x2a97('0x1a')]?_0x2992b6[_0x2a97('0x1a')][_0x2a97('0x1b')]||null:null,'attributes':_0x2992b6['options']?_0x2992b6[_0x2a97('0x1a')]['attributes']||null:null,'limit':_0x2992b6['options']?_0x2992b6[_0x2a97('0x1a')][_0x2a97('0x1c')]||null:null,'include':_0x2992b6[_0x2a97('0x1a')]?_0x2992b6['options']['include']?_[_0x2a97('0x1d')](_0x2992b6[_0x2a97('0x1a')]['include'],function(_0x215d5f){return{'model':db[_0x215d5f[_0x2a97('0x1e')]],'as':_0x215d5f['as'],'attributes':_0x215d5f['attributes'],'include':_0x215d5f[_0x2a97('0x1f')]?_[_0x2a97('0x1d')](_0x215d5f[_0x2a97('0x1f')],function(_0x2c08f4){return{'model':db[_0x2c08f4[_0x2a97('0x1e')]],'as':_0x2c08f4['as'],'attributes':_0x2c08f4[_0x2a97('0x20')],'include':_0x2c08f4[_0x2a97('0x1f')]?_['map'](_0x2c08f4['include'],function(_0x5b6d8c){return{'model':db[_0x5b6d8c[_0x2a97('0x1e')]],'as':_0x5b6d8c['as'],'attributes':_0x5b6d8c[_0x2a97('0x20')]};}):[]};}):[]};}):[]:[]})[_0x2a97('0x21')](function(_0x207509){logger[_0x2a97('0xf')](_0x2a97('0x22'),_0x2992b6);logger[_0x2a97('0x12')](_0x2a97('0x22'),_0x2992b6,JSON[_0x2a97('0x14')](_0x207509));_0x245f6b(_0x207509);})['catch'](function(_0x21fac1){logger[_0x2a97('0x15')]('GetVoiceQueueReport',_0x21fac1['message'],_0x2992b6);_0x52143b(_0x5d9b34[_0x2a97('0x15')](0x1f4,_0x21fac1[_0x2a97('0x17')]));});});};exports[_0x2a97('0x23')]=function(_0x5197dc){var _0xc85711=this;return new Promise(function(_0x2b2d7f,_0x152ba9){return db[_0x2a97('0x19')][_0x2a97('0x24')](_0x5197dc[_0x2a97('0x25')],{'raw':_0x5197dc[_0x2a97('0x1a')]?_0x5197dc['options']['raw']===undefined?!![]:![]:!![]})[_0x2a97('0x21')](function(_0x2d019e){logger[_0x2a97('0xf')]('CreateVoiceQueueReport',_0x5197dc);logger[_0x2a97('0x12')](_0x2a97('0x23'),_0x5197dc,JSON[_0x2a97('0x14')](_0x2d019e));_0x2b2d7f(_0x2d019e);})[_0x2a97('0x18')](function(_0x26831d){logger[_0x2a97('0x15')](_0x2a97('0x23'),_0x26831d[_0x2a97('0x17')],_0x5197dc);_0x152ba9(_0xc85711[_0x2a97('0x15')](0x1f4,_0x26831d[_0x2a97('0x17')]));});});};exports[_0x2a97('0x26')]=function(_0x24ef82){var _0x4d27c6=this;return new Promise(function(_0x583149,_0x65dc13){return db[_0x2a97('0x19')][_0x2a97('0x27')](_0x24ef82['body'],{'raw':_0x24ef82[_0x2a97('0x1a')]?_0x24ef82[_0x2a97('0x1a')][_0x2a97('0x28')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x24ef82[_0x2a97('0x1a')]?_0x24ef82[_0x2a97('0x1a')][_0x2a97('0x1b')]||null:null,'attributes':_0x24ef82[_0x2a97('0x1a')]?_0x24ef82['options']['attributes']||null:null,'limit':_0x24ef82[_0x2a97('0x1a')]?_0x24ef82[_0x2a97('0x1a')]['limit']||null:null})[_0x2a97('0x21')](function(_0x38ee7b){logger[_0x2a97('0xf')](_0x2a97('0x26'),_0x24ef82);logger[_0x2a97('0x12')](_0x2a97('0x26'),_0x24ef82,JSON[_0x2a97('0x14')](_0x38ee7b));_0x583149(_0x38ee7b);})[_0x2a97('0x18')](function(_0x307687){logger[_0x2a97('0x15')]('UpdateVoiceQueueReport',_0x307687['message'],_0x24ef82);_0x65dc13(_0x4d27c6['error'](0x1f4,_0x307687[_0x2a97('0x17')]));});});};