Built motion from commit b5413ace.|2.6.9
[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 _0x81b0=['code','message','catch','VoiceQueueReport','options','raw','where','attributes','limit','map','include','model','then','GetVoiceQueueReport','CreateVoiceQueueReport','create','UpdateVoiceQueueReport','update','body','lodash','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','redis','defaults','localhost','./voiceQueueReport.socket','register','info','VoiceQueueReport,\x20%s,\x20%s','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error'];(function(_0x36fdd6,_0x3e3f0a){var _0x23714f=function(_0x211bc3){while(--_0x211bc3){_0x36fdd6['push'](_0x36fdd6['shift']());}};_0x23714f(++_0x3e3f0a);}(_0x81b0,0xdb));var _0x081b=function(_0x46acb5,_0x14c147){_0x46acb5=_0x46acb5-0x0;var _0x3d9d02=_0x81b0[_0x46acb5];return _0x3d9d02;};'use strict';var _=require(_0x081b('0x0'));var util=require('util');var moment=require(_0x081b('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x081b('0x2'));var db=require(_0x081b('0x3'))['db'];var utils=require(_0x081b('0x4'));var logger=require(_0x081b('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0x081b('0x6'));var client=jayson[_0x081b('0x7')][_0x081b('0x8')]({'port':0x232a});config[_0x081b('0x9')]=_[_0x081b('0xa')](config[_0x081b('0x9')],{'host':_0x081b('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x081b('0x9')]));require(_0x081b('0xc'))[_0x081b('0xd')](socket);function respondWithRpcPromise(_0x303937,_0x150fec,_0x1b7a3c){return new BPromise(function(_0x2ccc46,_0x3832f1){return client['request'](_0x303937,_0x1b7a3c)['then'](function(_0x373134){logger[_0x081b('0xe')](_0x081b('0xf'),_0x150fec,'request\x20sent');logger[_0x081b('0x10')](_0x081b('0x11'),_0x150fec,_0x081b('0x12'),JSON[_0x081b('0x13')](_0x373134));if(_0x373134[_0x081b('0x14')]){if(_0x373134[_0x081b('0x14')][_0x081b('0x15')]===0x1f4){logger[_0x081b('0x14')](_0x081b('0xf'),_0x150fec,_0x373134[_0x081b('0x14')][_0x081b('0x16')]);return _0x3832f1(_0x373134['error']['message']);}logger['error'](_0x081b('0xf'),_0x150fec,_0x373134[_0x081b('0x14')][_0x081b('0x16')]);return _0x2ccc46(_0x373134['error'][_0x081b('0x16')]);}else{logger[_0x081b('0xe')](_0x081b('0xf'),_0x150fec,'request\x20sent');_0x2ccc46(_0x373134['result'][_0x081b('0x16')]);}})[_0x081b('0x17')](function(_0x2b38b1){logger[_0x081b('0x14')](_0x081b('0xf'),_0x150fec,_0x2b38b1);_0x3832f1(_0x2b38b1);});});}exports['GetVoiceQueueReport']=function(_0x2b4d3b){var _0x58e13d=this;return new Promise(function(_0xbbaca6,_0x2d4c77){return db[_0x081b('0x18')]['findAll']({'raw':_0x2b4d3b[_0x081b('0x19')]?_0x2b4d3b[_0x081b('0x19')][_0x081b('0x1a')]===undefined?!![]:![]:!![],'where':_0x2b4d3b[_0x081b('0x19')]?_0x2b4d3b['options'][_0x081b('0x1b')]||null:null,'attributes':_0x2b4d3b[_0x081b('0x19')]?_0x2b4d3b['options'][_0x081b('0x1c')]||null:null,'limit':_0x2b4d3b['options']?_0x2b4d3b[_0x081b('0x19')][_0x081b('0x1d')]||null:null,'include':_0x2b4d3b['options']?_0x2b4d3b[_0x081b('0x19')]['include']?_[_0x081b('0x1e')](_0x2b4d3b[_0x081b('0x19')][_0x081b('0x1f')],function(_0x1c8efe){return{'model':db[_0x1c8efe[_0x081b('0x20')]],'as':_0x1c8efe['as'],'attributes':_0x1c8efe[_0x081b('0x1c')],'include':_0x1c8efe[_0x081b('0x1f')]?_[_0x081b('0x1e')](_0x1c8efe[_0x081b('0x1f')],function(_0x598623){return{'model':db[_0x598623[_0x081b('0x20')]],'as':_0x598623['as'],'attributes':_0x598623[_0x081b('0x1c')],'include':_0x598623[_0x081b('0x1f')]?_['map'](_0x598623[_0x081b('0x1f')],function(_0x3f3002){return{'model':db[_0x3f3002[_0x081b('0x20')]],'as':_0x3f3002['as'],'attributes':_0x3f3002['attributes']};}):[]};}):[]};}):[]:[]})[_0x081b('0x21')](function(_0x634b3b){logger[_0x081b('0xe')](_0x081b('0x22'),_0x2b4d3b);logger[_0x081b('0x10')](_0x081b('0x22'),_0x2b4d3b,JSON['stringify'](_0x634b3b));_0xbbaca6(_0x634b3b);})[_0x081b('0x17')](function(_0x2ec03d){logger[_0x081b('0x14')]('GetVoiceQueueReport',_0x2ec03d[_0x081b('0x16')],_0x2b4d3b);_0x2d4c77(_0x58e13d['error'](0x1f4,_0x2ec03d['message']));});});};exports[_0x081b('0x23')]=function(_0x201a3c){var _0x242207=this;return new Promise(function(_0x2c1f75,_0x1dadcf){return db[_0x081b('0x18')][_0x081b('0x24')](_0x201a3c['body'],{'raw':_0x201a3c[_0x081b('0x19')]?_0x201a3c[_0x081b('0x19')][_0x081b('0x1a')]===undefined?!![]:![]:!![]})[_0x081b('0x21')](function(_0x125564){logger[_0x081b('0xe')](_0x081b('0x23'),_0x201a3c);logger[_0x081b('0x10')](_0x081b('0x23'),_0x201a3c,JSON[_0x081b('0x13')](_0x125564));_0x2c1f75(_0x125564);})[_0x081b('0x17')](function(_0x5bd9fd){logger[_0x081b('0x14')](_0x081b('0x23'),_0x5bd9fd['message'],_0x201a3c);_0x1dadcf(_0x242207['error'](0x1f4,_0x5bd9fd[_0x081b('0x16')]));});});};exports[_0x081b('0x25')]=function(_0x2000fb){var _0x58320b=this;return new Promise(function(_0x64f339,_0x4e1ea9){return db[_0x081b('0x18')][_0x081b('0x26')](_0x2000fb[_0x081b('0x27')],{'raw':_0x2000fb[_0x081b('0x19')]?_0x2000fb[_0x081b('0x19')][_0x081b('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2000fb['options']?_0x2000fb[_0x081b('0x19')][_0x081b('0x1b')]||null:null,'attributes':_0x2000fb[_0x081b('0x19')]?_0x2000fb['options']['attributes']||null:null,'limit':_0x2000fb['options']?_0x2000fb['options'][_0x081b('0x1d')]||null:null})[_0x081b('0x21')](function(_0x268787){logger[_0x081b('0xe')]('UpdateVoiceQueueReport',_0x2000fb);logger[_0x081b('0x10')](_0x081b('0x25'),_0x2000fb,JSON[_0x081b('0x13')](_0x268787));_0x64f339(_0x268787);})[_0x081b('0x17')](function(_0x2ba7f1){logger['error'](_0x081b('0x25'),_0x2ba7f1[_0x081b('0x16')],_0x2000fb);_0x4e1ea9(_0x58320b['error'](0x1f4,_0x2ba7f1['message']));});});};