Built motion from commit a679711e.|2.6.15
[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 _0x0652=['options','raw','where','limit','map','include','model','attributes','GetVoiceQueueReport','debug','CreateVoiceQueueReport','body','stringify','UpdateVoiceQueueReport','update','lodash','util','bluebird','randomstring','ioredis','rpc','../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./voiceQueueReport.socket','register','request','then','info','VoiceQueueReport,\x20%s,\x20%s,\x20%s','error','VoiceQueueReport,\x20%s,\x20%s','message','result','catch','VoiceQueueReport'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x0652,0xaf));var _0x2065=function(_0x522dde,_0x3d85b3){_0x522dde=_0x522dde-0x0;var _0x5e7231=_0x0652[_0x522dde];return _0x5e7231;};'use strict';var _=require(_0x2065('0x0'));var util=require(_0x2065('0x1'));var moment=require('moment');var BPromise=require(_0x2065('0x2'));var rs=require(_0x2065('0x3'));var fs=require('fs');var Redis=require(_0x2065('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x2065('0x5'));var config=require(_0x2065('0x6'));var jayson=require(_0x2065('0x7'));var client=jayson[_0x2065('0x8')][_0x2065('0x9')]({'port':0x232a});config[_0x2065('0xa')]=_['defaults'](config[_0x2065('0xa')],{'host':_0x2065('0xb'),'port':0x18eb});var socket=require(_0x2065('0xc'))(new Redis(config[_0x2065('0xa')]));require(_0x2065('0xd'))[_0x2065('0xe')](socket);function respondWithRpcPromise(_0x43f7c5,_0x22c99a,_0x49475b){return new BPromise(function(_0x296a10,_0x51d12c){return client[_0x2065('0xf')](_0x43f7c5,_0x49475b)[_0x2065('0x10')](function(_0x255491){logger[_0x2065('0x11')]('VoiceQueueReport,\x20%s,\x20%s',_0x22c99a,'request\x20sent');logger['debug'](_0x2065('0x12'),_0x22c99a,'request\x20sent',JSON['stringify'](_0x255491));if(_0x255491[_0x2065('0x13')]){if(_0x255491[_0x2065('0x13')]['code']===0x1f4){logger[_0x2065('0x13')](_0x2065('0x14'),_0x22c99a,_0x255491[_0x2065('0x13')][_0x2065('0x15')]);return _0x51d12c(_0x255491['error']['message']);}logger[_0x2065('0x13')](_0x2065('0x14'),_0x22c99a,_0x255491[_0x2065('0x13')]['message']);return _0x296a10(_0x255491['error'][_0x2065('0x15')]);}else{logger[_0x2065('0x11')](_0x2065('0x14'),_0x22c99a,'request\x20sent');_0x296a10(_0x255491[_0x2065('0x16')][_0x2065('0x15')]);}})[_0x2065('0x17')](function(_0x20e442){logger[_0x2065('0x13')](_0x2065('0x14'),_0x22c99a,_0x20e442);_0x51d12c(_0x20e442);});});}exports['GetVoiceQueueReport']=function(_0x30fa44){var _0x53eb4c=this;return new Promise(function(_0x433aee,_0x1290a2){return db[_0x2065('0x18')]['findAll']({'raw':_0x30fa44['options']?_0x30fa44[_0x2065('0x19')][_0x2065('0x1a')]===undefined?!![]:![]:!![],'where':_0x30fa44[_0x2065('0x19')]?_0x30fa44[_0x2065('0x19')][_0x2065('0x1b')]||null:null,'attributes':_0x30fa44[_0x2065('0x19')]?_0x30fa44[_0x2065('0x19')]['attributes']||null:null,'limit':_0x30fa44[_0x2065('0x19')]?_0x30fa44['options'][_0x2065('0x1c')]||null:null,'include':_0x30fa44[_0x2065('0x19')]?_0x30fa44[_0x2065('0x19')]['include']?_[_0x2065('0x1d')](_0x30fa44[_0x2065('0x19')][_0x2065('0x1e')],function(_0x29866d){return{'model':db[_0x29866d[_0x2065('0x1f')]],'as':_0x29866d['as'],'attributes':_0x29866d[_0x2065('0x20')],'include':_0x29866d[_0x2065('0x1e')]?_['map'](_0x29866d['include'],function(_0x5c1768){return{'model':db[_0x5c1768[_0x2065('0x1f')]],'as':_0x5c1768['as'],'attributes':_0x5c1768[_0x2065('0x20')],'include':_0x5c1768[_0x2065('0x1e')]?_['map'](_0x5c1768[_0x2065('0x1e')],function(_0x164adc){return{'model':db[_0x164adc[_0x2065('0x1f')]],'as':_0x164adc['as'],'attributes':_0x164adc[_0x2065('0x20')]};}):[]};}):[]};}):[]:[]})[_0x2065('0x10')](function(_0x46edf5){logger[_0x2065('0x11')](_0x2065('0x21'),_0x30fa44);logger[_0x2065('0x22')](_0x2065('0x21'),_0x30fa44,JSON['stringify'](_0x46edf5));_0x433aee(_0x46edf5);})['catch'](function(_0x5a3ff3){logger[_0x2065('0x13')](_0x2065('0x21'),_0x5a3ff3[_0x2065('0x15')],_0x30fa44);_0x1290a2(_0x53eb4c[_0x2065('0x13')](0x1f4,_0x5a3ff3['message']));});});};exports[_0x2065('0x23')]=function(_0x2c0465){var _0x3843d2=this;return new Promise(function(_0x21304a,_0x3eeb8c){return db[_0x2065('0x18')]['create'](_0x2c0465[_0x2065('0x24')],{'raw':_0x2c0465[_0x2065('0x19')]?_0x2c0465[_0x2065('0x19')][_0x2065('0x1a')]===undefined?!![]:![]:!![]})[_0x2065('0x10')](function(_0x171857){logger[_0x2065('0x11')]('CreateVoiceQueueReport',_0x2c0465);logger['debug'](_0x2065('0x23'),_0x2c0465,JSON[_0x2065('0x25')](_0x171857));_0x21304a(_0x171857);})['catch'](function(_0x51a496){logger['error'](_0x2065('0x23'),_0x51a496['message'],_0x2c0465);_0x3eeb8c(_0x3843d2[_0x2065('0x13')](0x1f4,_0x51a496[_0x2065('0x15')]));});});};exports[_0x2065('0x26')]=function(_0x42adc2){var _0x3c2ebe=this;return new Promise(function(_0x149bfa,_0x5d7184){return db['VoiceQueueReport'][_0x2065('0x27')](_0x42adc2['body'],{'raw':_0x42adc2[_0x2065('0x19')]?_0x42adc2[_0x2065('0x19')][_0x2065('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x42adc2[_0x2065('0x19')]?_0x42adc2['options'][_0x2065('0x1b')]||null:null,'attributes':_0x42adc2[_0x2065('0x19')]?_0x42adc2[_0x2065('0x19')][_0x2065('0x20')]||null:null,'limit':_0x42adc2['options']?_0x42adc2['options'][_0x2065('0x1c')]||null:null})[_0x2065('0x10')](function(_0x3abf1e){logger['info'](_0x2065('0x26'),_0x42adc2);logger[_0x2065('0x22')](_0x2065('0x26'),_0x42adc2,JSON[_0x2065('0x25')](_0x3abf1e));_0x149bfa(_0x3abf1e);})['catch'](function(_0x346e69){logger[_0x2065('0x13')](_0x2065('0x26'),_0x346e69['message'],_0x42adc2);_0x5d7184(_0x3c2ebe[_0x2065('0x13')](0x1f4,_0x346e69[_0x2065('0x15')]));});});};