Built motion from commit 25580385.|2.6.2
[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 _0xfd80=['map','CreateVoiceQueueReport','create','body','UpdateVoiceQueueReport','update','raw','lodash','moment','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./voiceQueueReport.socket','register','request','then','info','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','VoiceQueueReport,\x20%s,\x20%s','catch','GetVoiceQueueReport','VoiceQueueReport','options','attributes','limit','model','include'];(function(_0x298eb7,_0x39cd4d){var _0x53b5f1=function(_0x5c7cee){while(--_0x5c7cee){_0x298eb7['push'](_0x298eb7['shift']());}};_0x53b5f1(++_0x39cd4d);}(_0xfd80,0x147));var _0x0fd8=function(_0x48d0cf,_0x4d71b8){_0x48d0cf=_0x48d0cf-0x0;var _0x2fa1b4=_0xfd80[_0x48d0cf];return _0x2fa1b4;};'use strict';var _=require(_0x0fd8('0x0'));var util=require('util');var moment=require(_0x0fd8('0x1'));var BPromise=require(_0x0fd8('0x2'));var rs=require(_0x0fd8('0x3'));var fs=require('fs');var Redis=require(_0x0fd8('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x0fd8('0x5'))('rpc');var config=require(_0x0fd8('0x6'));var jayson=require(_0x0fd8('0x7'));var client=jayson[_0x0fd8('0x8')][_0x0fd8('0x9')]({'port':0x232a});config[_0x0fd8('0xa')]=_[_0x0fd8('0xb')](config[_0x0fd8('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x0fd8('0xc'))(new Redis(config[_0x0fd8('0xa')]));require(_0x0fd8('0xd'))[_0x0fd8('0xe')](socket);function respondWithRpcPromise(_0x1546dd,_0xf40a76,_0x1f6268){return new BPromise(function(_0x5108f0,_0x404a02){return client[_0x0fd8('0xf')](_0x1546dd,_0x1f6268)[_0x0fd8('0x10')](function(_0x3be92c){logger[_0x0fd8('0x11')]('VoiceQueueReport,\x20%s,\x20%s',_0xf40a76,_0x0fd8('0x12'));logger[_0x0fd8('0x13')](_0x0fd8('0x14'),_0xf40a76,_0x0fd8('0x12'),JSON[_0x0fd8('0x15')](_0x3be92c));if(_0x3be92c[_0x0fd8('0x16')]){if(_0x3be92c[_0x0fd8('0x16')]['code']===0x1f4){logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0xf40a76,_0x3be92c[_0x0fd8('0x16')][_0x0fd8('0x17')]);return _0x404a02(_0x3be92c[_0x0fd8('0x16')][_0x0fd8('0x17')]);}logger[_0x0fd8('0x16')]('VoiceQueueReport,\x20%s,\x20%s',_0xf40a76,_0x3be92c[_0x0fd8('0x16')][_0x0fd8('0x17')]);return _0x5108f0(_0x3be92c['error'][_0x0fd8('0x17')]);}else{logger[_0x0fd8('0x11')](_0x0fd8('0x18'),_0xf40a76,_0x0fd8('0x12'));_0x5108f0(_0x3be92c['result'][_0x0fd8('0x17')]);}})[_0x0fd8('0x19')](function(_0x35c689){logger[_0x0fd8('0x16')](_0x0fd8('0x18'),_0xf40a76,_0x35c689);_0x404a02(_0x35c689);});});}exports[_0x0fd8('0x1a')]=function(_0x360890){var _0x52d036=this;return new Promise(function(_0x2f9095,_0xbbf225){return db[_0x0fd8('0x1b')]['findAll']({'raw':_0x360890[_0x0fd8('0x1c')]?_0x360890['options']['raw']===undefined?!![]:![]:!![],'where':_0x360890[_0x0fd8('0x1c')]?_0x360890['options']['where']||null:null,'attributes':_0x360890[_0x0fd8('0x1c')]?_0x360890[_0x0fd8('0x1c')][_0x0fd8('0x1d')]||null:null,'limit':_0x360890[_0x0fd8('0x1c')]?_0x360890[_0x0fd8('0x1c')][_0x0fd8('0x1e')]||null:null,'include':_0x360890['options']?_0x360890[_0x0fd8('0x1c')]['include']?_['map'](_0x360890['options']['include'],function(_0x403fce){return{'model':db[_0x403fce[_0x0fd8('0x1f')]],'as':_0x403fce['as'],'attributes':_0x403fce[_0x0fd8('0x1d')],'include':_0x403fce[_0x0fd8('0x20')]?_[_0x0fd8('0x21')](_0x403fce[_0x0fd8('0x20')],function(_0x4013fb){return{'model':db[_0x4013fb['model']],'as':_0x4013fb['as'],'attributes':_0x4013fb[_0x0fd8('0x1d')],'include':_0x4013fb[_0x0fd8('0x20')]?_['map'](_0x4013fb[_0x0fd8('0x20')],function(_0x4060a7){return{'model':db[_0x4060a7[_0x0fd8('0x1f')]],'as':_0x4060a7['as'],'attributes':_0x4060a7[_0x0fd8('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x8ed2a0){logger['info'](_0x0fd8('0x1a'),_0x360890);logger[_0x0fd8('0x13')](_0x0fd8('0x1a'),_0x360890,JSON[_0x0fd8('0x15')](_0x8ed2a0));_0x2f9095(_0x8ed2a0);})['catch'](function(_0x14b670){logger[_0x0fd8('0x16')](_0x0fd8('0x1a'),_0x14b670[_0x0fd8('0x17')],_0x360890);_0xbbf225(_0x52d036[_0x0fd8('0x16')](0x1f4,_0x14b670[_0x0fd8('0x17')]));});});};exports[_0x0fd8('0x22')]=function(_0x26bc1d){var _0x4de727=this;return new Promise(function(_0x3e9139,_0x172983){return db['VoiceQueueReport'][_0x0fd8('0x23')](_0x26bc1d[_0x0fd8('0x24')],{'raw':_0x26bc1d[_0x0fd8('0x1c')]?_0x26bc1d[_0x0fd8('0x1c')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x59b55f){logger[_0x0fd8('0x11')](_0x0fd8('0x22'),_0x26bc1d);logger[_0x0fd8('0x13')](_0x0fd8('0x22'),_0x26bc1d,JSON['stringify'](_0x59b55f));_0x3e9139(_0x59b55f);})['catch'](function(_0x42f265){logger[_0x0fd8('0x16')]('CreateVoiceQueueReport',_0x42f265['message'],_0x26bc1d);_0x172983(_0x4de727[_0x0fd8('0x16')](0x1f4,_0x42f265[_0x0fd8('0x17')]));});});};exports[_0x0fd8('0x25')]=function(_0x12adbc){var _0x53767d=this;return new Promise(function(_0x298130,_0x5bc5c2){return db[_0x0fd8('0x1b')][_0x0fd8('0x26')](_0x12adbc[_0x0fd8('0x24')],{'raw':_0x12adbc['options']?_0x12adbc[_0x0fd8('0x1c')][_0x0fd8('0x27')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x12adbc[_0x0fd8('0x1c')]?_0x12adbc[_0x0fd8('0x1c')]['where']||null:null,'attributes':_0x12adbc['options']?_0x12adbc[_0x0fd8('0x1c')]['attributes']||null:null,'limit':_0x12adbc['options']?_0x12adbc[_0x0fd8('0x1c')]['limit']||null:null})['then'](function(_0x1d608f){logger[_0x0fd8('0x11')](_0x0fd8('0x25'),_0x12adbc);logger[_0x0fd8('0x13')]('UpdateVoiceQueueReport',_0x12adbc,JSON['stringify'](_0x1d608f));_0x298130(_0x1d608f);})[_0x0fd8('0x19')](function(_0x4cfaeb){logger[_0x0fd8('0x16')](_0x0fd8('0x25'),_0x4cfaeb[_0x0fd8('0x17')],_0x12adbc);_0x5bc5c2(_0x53767d[_0x0fd8('0x16')](0x1f4,_0x4cfaeb[_0x0fd8('0x17')]));});});};