43ad5f26e1e4c399d83f668dba89cc204f4bfe21
[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 _0x5901=['debug','stringify','error','code','message','catch','VoiceQueueReport','findAll','options','raw','where','limit','include','map','model','attributes','then','GetVoiceQueueReport','CreateVoiceQueueReport','create','update','body','UpdateVoiceQueueReport','lodash','util','moment','bluebird','../../mysqldb','../../config/logger','jayson/promise','client','redis','defaults','socket.io-emitter','register','request','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent'];(function(_0x184b3d,_0x504fbc){var _0x27f867=function(_0x2929ad){while(--_0x2929ad){_0x184b3d['push'](_0x184b3d['shift']());}};_0x27f867(++_0x504fbc);}(_0x5901,0x101));var _0x1590=function(_0x51c921,_0x12e846){_0x51c921=_0x51c921-0x0;var _0x57886f=_0x5901[_0x51c921];return _0x57886f;};'use strict';var _=require(_0x1590('0x0'));var util=require(_0x1590('0x1'));var moment=require(_0x1590('0x2'));var BPromise=require(_0x1590('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x1590('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x1590('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0x1590('0x6'));var client=jayson[_0x1590('0x7')]['http']({'port':0x232a});config[_0x1590('0x8')]=_[_0x1590('0x9')](config[_0x1590('0x8')],{'host':'localhost','port':0x18eb});var socket=require(_0x1590('0xa'))(new Redis(config[_0x1590('0x8')]));require('./voiceQueueReport.socket')[_0x1590('0xb')](socket);function respondWithRpcPromise(_0xfc6f77,_0x2a2cda,_0x45443d){return new BPromise(function(_0x40d399,_0x48ebdb){return client[_0x1590('0xc')](_0xfc6f77,_0x45443d)['then'](function(_0x50aa85){logger[_0x1590('0xd')](_0x1590('0xe'),_0x2a2cda,_0x1590('0xf'));logger[_0x1590('0x10')]('VoiceQueueReport,\x20%s,\x20%s,\x20%s',_0x2a2cda,'request\x20sent',JSON[_0x1590('0x11')](_0x50aa85));if(_0x50aa85['error']){if(_0x50aa85[_0x1590('0x12')][_0x1590('0x13')]===0x1f4){logger[_0x1590('0x12')](_0x1590('0xe'),_0x2a2cda,_0x50aa85[_0x1590('0x12')][_0x1590('0x14')]);return _0x48ebdb(_0x50aa85[_0x1590('0x12')]['message']);}logger[_0x1590('0x12')](_0x1590('0xe'),_0x2a2cda,_0x50aa85[_0x1590('0x12')]['message']);return _0x40d399(_0x50aa85[_0x1590('0x12')][_0x1590('0x14')]);}else{logger[_0x1590('0xd')](_0x1590('0xe'),_0x2a2cda,_0x1590('0xf'));_0x40d399(_0x50aa85['result'][_0x1590('0x14')]);}})[_0x1590('0x15')](function(_0x473cb9){logger[_0x1590('0x12')](_0x1590('0xe'),_0x2a2cda,_0x473cb9);_0x48ebdb(_0x473cb9);});});}exports['GetVoiceQueueReport']=function(_0x43b765){var _0x491c56=this;return new Promise(function(_0x368194,_0x8378fe){return db[_0x1590('0x16')][_0x1590('0x17')]({'raw':_0x43b765[_0x1590('0x18')]?_0x43b765[_0x1590('0x18')][_0x1590('0x19')]===undefined?!![]:![]:!![],'where':_0x43b765[_0x1590('0x18')]?_0x43b765[_0x1590('0x18')][_0x1590('0x1a')]||null:null,'attributes':_0x43b765[_0x1590('0x18')]?_0x43b765['options']['attributes']||null:null,'limit':_0x43b765[_0x1590('0x18')]?_0x43b765['options'][_0x1590('0x1b')]||null:null,'include':_0x43b765[_0x1590('0x18')]?_0x43b765[_0x1590('0x18')][_0x1590('0x1c')]?_[_0x1590('0x1d')](_0x43b765[_0x1590('0x18')][_0x1590('0x1c')],function(_0x551a46){return{'model':db[_0x551a46[_0x1590('0x1e')]],'as':_0x551a46['as'],'attributes':_0x551a46[_0x1590('0x1f')],'include':_0x551a46[_0x1590('0x1c')]?_[_0x1590('0x1d')](_0x551a46[_0x1590('0x1c')],function(_0x530a1c){return{'model':db[_0x530a1c['model']],'as':_0x530a1c['as'],'attributes':_0x530a1c[_0x1590('0x1f')],'include':_0x530a1c[_0x1590('0x1c')]?_['map'](_0x530a1c[_0x1590('0x1c')],function(_0x599a1b){return{'model':db[_0x599a1b[_0x1590('0x1e')]],'as':_0x599a1b['as'],'attributes':_0x599a1b[_0x1590('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x1590('0x20')](function(_0x27877a){logger[_0x1590('0xd')]('GetVoiceQueueReport',_0x43b765);logger[_0x1590('0x10')](_0x1590('0x21'),_0x43b765,JSON[_0x1590('0x11')](_0x27877a));_0x368194(_0x27877a);})[_0x1590('0x15')](function(_0x5220e1){logger[_0x1590('0x12')]('GetVoiceQueueReport',_0x5220e1['message'],_0x43b765);_0x8378fe(_0x491c56[_0x1590('0x12')](0x1f4,_0x5220e1[_0x1590('0x14')]));});});};exports[_0x1590('0x22')]=function(_0x4e709f){var _0x40d5da=this;return new Promise(function(_0x1121c0,_0x18e205){return db[_0x1590('0x16')][_0x1590('0x23')](_0x4e709f['body'],{'raw':_0x4e709f[_0x1590('0x18')]?_0x4e709f['options'][_0x1590('0x19')]===undefined?!![]:![]:!![]})[_0x1590('0x20')](function(_0x4f9548){logger['info'](_0x1590('0x22'),_0x4e709f);logger[_0x1590('0x10')]('CreateVoiceQueueReport',_0x4e709f,JSON[_0x1590('0x11')](_0x4f9548));_0x1121c0(_0x4f9548);})[_0x1590('0x15')](function(_0xad34c){logger['error'](_0x1590('0x22'),_0xad34c[_0x1590('0x14')],_0x4e709f);_0x18e205(_0x40d5da[_0x1590('0x12')](0x1f4,_0xad34c[_0x1590('0x14')]));});});};exports['UpdateVoiceQueueReport']=function(_0x245c8f){var _0x1f8431=this;return new Promise(function(_0x321d70,_0x30369c){return db[_0x1590('0x16')][_0x1590('0x24')](_0x245c8f[_0x1590('0x25')],{'raw':_0x245c8f[_0x1590('0x18')]?_0x245c8f[_0x1590('0x18')][_0x1590('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x245c8f[_0x1590('0x18')]?_0x245c8f['options']['where']||null:null,'attributes':_0x245c8f[_0x1590('0x18')]?_0x245c8f[_0x1590('0x18')][_0x1590('0x1f')]||null:null,'limit':_0x245c8f[_0x1590('0x18')]?_0x245c8f['options']['limit']||null:null})[_0x1590('0x20')](function(_0x388fd3){logger['info'](_0x1590('0x26'),_0x245c8f);logger[_0x1590('0x10')]('UpdateVoiceQueueReport',_0x245c8f,JSON['stringify'](_0x388fd3));_0x321d70(_0x388fd3);})[_0x1590('0x15')](function(_0x547839){logger['error'](_0x1590('0x26'),_0x547839[_0x1590('0x14')],_0x245c8f);_0x30369c(_0x1f8431[_0x1590('0x12')](0x1f4,_0x547839[_0x1590('0x14')]));});});};