2db2ec9eb5b12279a41c7a6a18bae8e699355024
[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 _0x31b6=['include','model','map','create','body','raw','CreateVoiceQueueReport','update','UpdateVoiceQueueReport','lodash','util','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','redis','localhost','socket.io-emitter','./voiceQueueReport.socket','register','request','then','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','GetVoiceQueueReport','VoiceQueueReport','findAll','options','where','attributes','limit'];(function(_0x4a53d,_0x58a95e){var _0x27410e=function(_0x38fc90){while(--_0x38fc90){_0x4a53d['push'](_0x4a53d['shift']());}};_0x27410e(++_0x58a95e);}(_0x31b6,0xe5));var _0x631b=function(_0x3e079f,_0x189e15){_0x3e079f=_0x3e079f-0x0;var _0x296a34=_0x31b6[_0x3e079f];return _0x296a34;};'use strict';var _=require(_0x631b('0x0'));var util=require(_0x631b('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x631b('0x2'));var fs=require('fs');var Redis=require(_0x631b('0x3'));var db=require(_0x631b('0x4'))['db'];var utils=require(_0x631b('0x5'));var logger=require('../../config/logger')(_0x631b('0x6'));var config=require(_0x631b('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x631b('0x8')][_0x631b('0x9')]({'port':0x232a});config[_0x631b('0xa')]=_['defaults'](config[_0x631b('0xa')],{'host':_0x631b('0xb'),'port':0x18eb});var socket=require(_0x631b('0xc'))(new Redis(config['redis']));require(_0x631b('0xd'))[_0x631b('0xe')](socket);function respondWithRpcPromise(_0x3c29ee,_0x39f290,_0x16fc7b){return new BPromise(function(_0x5554f8,_0x2f9ad2){return client[_0x631b('0xf')](_0x3c29ee,_0x16fc7b)[_0x631b('0x10')](function(_0x600748){logger['info'](_0x631b('0x11'),_0x39f290,_0x631b('0x12'));logger[_0x631b('0x13')](_0x631b('0x14'),_0x39f290,_0x631b('0x12'),JSON[_0x631b('0x15')](_0x600748));if(_0x600748[_0x631b('0x16')]){if(_0x600748[_0x631b('0x16')][_0x631b('0x17')]===0x1f4){logger['error'](_0x631b('0x11'),_0x39f290,_0x600748[_0x631b('0x16')]['message']);return _0x2f9ad2(_0x600748[_0x631b('0x16')][_0x631b('0x18')]);}logger[_0x631b('0x16')](_0x631b('0x11'),_0x39f290,_0x600748['error']['message']);return _0x5554f8(_0x600748[_0x631b('0x16')][_0x631b('0x18')]);}else{logger[_0x631b('0x19')](_0x631b('0x11'),_0x39f290,_0x631b('0x12'));_0x5554f8(_0x600748[_0x631b('0x1a')][_0x631b('0x18')]);}})[_0x631b('0x1b')](function(_0x5c6460){logger[_0x631b('0x16')]('VoiceQueueReport,\x20%s,\x20%s',_0x39f290,_0x5c6460);_0x2f9ad2(_0x5c6460);});});}exports[_0x631b('0x1c')]=function(_0x2414c5){var _0x26a3af=this;return new Promise(function(_0x211e48,_0x5d8042){return db[_0x631b('0x1d')][_0x631b('0x1e')]({'raw':_0x2414c5[_0x631b('0x1f')]?_0x2414c5[_0x631b('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0x2414c5[_0x631b('0x1f')]?_0x2414c5[_0x631b('0x1f')][_0x631b('0x20')]||null:null,'attributes':_0x2414c5['options']?_0x2414c5[_0x631b('0x1f')][_0x631b('0x21')]||null:null,'limit':_0x2414c5[_0x631b('0x1f')]?_0x2414c5[_0x631b('0x1f')][_0x631b('0x22')]||null:null,'include':_0x2414c5[_0x631b('0x1f')]?_0x2414c5[_0x631b('0x1f')][_0x631b('0x23')]?_['map'](_0x2414c5[_0x631b('0x1f')][_0x631b('0x23')],function(_0x1509f7){return{'model':db[_0x1509f7[_0x631b('0x24')]],'as':_0x1509f7['as'],'attributes':_0x1509f7[_0x631b('0x21')],'include':_0x1509f7[_0x631b('0x23')]?_[_0x631b('0x25')](_0x1509f7[_0x631b('0x23')],function(_0x4e5ea0){return{'model':db[_0x4e5ea0[_0x631b('0x24')]],'as':_0x4e5ea0['as'],'attributes':_0x4e5ea0[_0x631b('0x21')],'include':_0x4e5ea0[_0x631b('0x23')]?_[_0x631b('0x25')](_0x4e5ea0[_0x631b('0x23')],function(_0x5c29df){return{'model':db[_0x5c29df['model']],'as':_0x5c29df['as'],'attributes':_0x5c29df[_0x631b('0x21')]};}):[]};}):[]};}):[]:[]})[_0x631b('0x10')](function(_0x584144){logger[_0x631b('0x19')](_0x631b('0x1c'),_0x2414c5);logger[_0x631b('0x13')](_0x631b('0x1c'),_0x2414c5,JSON[_0x631b('0x15')](_0x584144));_0x211e48(_0x584144);})['catch'](function(_0x1f9f7b){logger[_0x631b('0x16')](_0x631b('0x1c'),_0x1f9f7b[_0x631b('0x18')],_0x2414c5);_0x5d8042(_0x26a3af[_0x631b('0x16')](0x1f4,_0x1f9f7b[_0x631b('0x18')]));});});};exports['CreateVoiceQueueReport']=function(_0x4c1822){var _0x1b0404=this;return new Promise(function(_0x5e5a31,_0xa30918){return db['VoiceQueueReport'][_0x631b('0x26')](_0x4c1822[_0x631b('0x27')],{'raw':_0x4c1822['options']?_0x4c1822[_0x631b('0x1f')][_0x631b('0x28')]===undefined?!![]:![]:!![]})[_0x631b('0x10')](function(_0x9c4551){logger['info']('CreateVoiceQueueReport',_0x4c1822);logger['debug'](_0x631b('0x29'),_0x4c1822,JSON[_0x631b('0x15')](_0x9c4551));_0x5e5a31(_0x9c4551);})[_0x631b('0x1b')](function(_0xe9f318){logger[_0x631b('0x16')](_0x631b('0x29'),_0xe9f318[_0x631b('0x18')],_0x4c1822);_0xa30918(_0x1b0404[_0x631b('0x16')](0x1f4,_0xe9f318[_0x631b('0x18')]));});});};exports['UpdateVoiceQueueReport']=function(_0x23722a){var _0x42987d=this;return new Promise(function(_0x122c11,_0x241c6b){return db[_0x631b('0x1d')][_0x631b('0x2a')](_0x23722a['body'],{'raw':_0x23722a['options']?_0x23722a[_0x631b('0x1f')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x23722a['options']?_0x23722a[_0x631b('0x1f')][_0x631b('0x20')]||null:null,'attributes':_0x23722a[_0x631b('0x1f')]?_0x23722a[_0x631b('0x1f')][_0x631b('0x21')]||null:null,'limit':_0x23722a['options']?_0x23722a[_0x631b('0x1f')][_0x631b('0x22')]||null:null})[_0x631b('0x10')](function(_0x44f114){logger[_0x631b('0x19')](_0x631b('0x2b'),_0x23722a);logger[_0x631b('0x13')](_0x631b('0x2b'),_0x23722a,JSON['stringify'](_0x44f114));_0x122c11(_0x44f114);})['catch'](function(_0x131be2){logger[_0x631b('0x16')](_0x631b('0x2b'),_0x131be2[_0x631b('0x18')],_0x23722a);_0x241c6b(_0x42987d['error'](0x1f4,_0x131be2[_0x631b('0x18')]));});});};