bcdc639ab8c30c3785452f8893b9b0de8ba409b2
[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 _0x8296=['../../mysqldb','../../config/utils','../../config/logger','jayson/promise','http','defaults','redis','localhost','socket.io-emitter','register','request','then','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetVoiceQueueReport','VoiceQueueReport','findAll','options','raw','where','limit','include','map','model','attributes','CreateVoiceQueueReport','body','UpdateVoiceQueueReport','update','lodash','util','moment','bluebird','randomstring'];(function(_0x186847,_0x4b823a){var _0x57e29d=function(_0x155ca5){while(--_0x155ca5){_0x186847['push'](_0x186847['shift']());}};_0x57e29d(++_0x4b823a);}(_0x8296,0x1a9));var _0x6829=function(_0x4e806d,_0x4cc01d){_0x4e806d=_0x4e806d-0x0;var _0x20821f=_0x8296[_0x4e806d];return _0x20821f;};'use strict';var _=require(_0x6829('0x0'));var util=require(_0x6829('0x1'));var moment=require(_0x6829('0x2'));var BPromise=require(_0x6829('0x3'));var rs=require(_0x6829('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6829('0x5'))['db'];var utils=require(_0x6829('0x6'));var logger=require(_0x6829('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x6829('0x8'));var client=jayson['client'][_0x6829('0x9')]({'port':0x232a});config['redis']=_[_0x6829('0xa')](config[_0x6829('0xb')],{'host':_0x6829('0xc'),'port':0x18eb});var socket=require(_0x6829('0xd'))(new Redis(config[_0x6829('0xb')]));require('./voiceQueueReport.socket')[_0x6829('0xe')](socket);function respondWithRpcPromise(_0x319f48,_0x31b77c,_0x373752){return new BPromise(function(_0x513c13,_0x114f56){return client[_0x6829('0xf')](_0x319f48,_0x373752)[_0x6829('0x10')](function(_0x427b5e){logger[_0x6829('0x11')](_0x6829('0x12'),_0x31b77c,_0x6829('0x13'));logger[_0x6829('0x14')](_0x6829('0x15'),_0x31b77c,_0x6829('0x13'),JSON[_0x6829('0x16')](_0x427b5e));if(_0x427b5e[_0x6829('0x17')]){if(_0x427b5e['error'][_0x6829('0x18')]===0x1f4){logger[_0x6829('0x17')]('VoiceQueueReport,\x20%s,\x20%s',_0x31b77c,_0x427b5e['error'][_0x6829('0x19')]);return _0x114f56(_0x427b5e[_0x6829('0x17')][_0x6829('0x19')]);}logger[_0x6829('0x17')](_0x6829('0x12'),_0x31b77c,_0x427b5e[_0x6829('0x17')]['message']);return _0x513c13(_0x427b5e[_0x6829('0x17')][_0x6829('0x19')]);}else{logger['info']('VoiceQueueReport,\x20%s,\x20%s',_0x31b77c,_0x6829('0x13'));_0x513c13(_0x427b5e[_0x6829('0x1a')][_0x6829('0x19')]);}})[_0x6829('0x1b')](function(_0x3e9686){logger[_0x6829('0x17')](_0x6829('0x12'),_0x31b77c,_0x3e9686);_0x114f56(_0x3e9686);});});}exports[_0x6829('0x1c')]=function(_0x63f4c5){var _0x1f4d36=this;return new Promise(function(_0x36253e,_0x55dbe3){return db[_0x6829('0x1d')][_0x6829('0x1e')]({'raw':_0x63f4c5[_0x6829('0x1f')]?_0x63f4c5[_0x6829('0x1f')][_0x6829('0x20')]===undefined?!![]:![]:!![],'where':_0x63f4c5[_0x6829('0x1f')]?_0x63f4c5[_0x6829('0x1f')][_0x6829('0x21')]||null:null,'attributes':_0x63f4c5['options']?_0x63f4c5['options']['attributes']||null:null,'limit':_0x63f4c5['options']?_0x63f4c5['options'][_0x6829('0x22')]||null:null,'include':_0x63f4c5[_0x6829('0x1f')]?_0x63f4c5[_0x6829('0x1f')][_0x6829('0x23')]?_[_0x6829('0x24')](_0x63f4c5[_0x6829('0x1f')]['include'],function(_0x181894){return{'model':db[_0x181894[_0x6829('0x25')]],'as':_0x181894['as'],'attributes':_0x181894[_0x6829('0x26')],'include':_0x181894[_0x6829('0x23')]?_[_0x6829('0x24')](_0x181894['include'],function(_0x300c4e){return{'model':db[_0x300c4e[_0x6829('0x25')]],'as':_0x300c4e['as'],'attributes':_0x300c4e[_0x6829('0x26')],'include':_0x300c4e[_0x6829('0x23')]?_[_0x6829('0x24')](_0x300c4e[_0x6829('0x23')],function(_0x27004b){return{'model':db[_0x27004b[_0x6829('0x25')]],'as':_0x27004b['as'],'attributes':_0x27004b[_0x6829('0x26')]};}):[]};}):[]};}):[]:[]})[_0x6829('0x10')](function(_0x32a932){logger[_0x6829('0x11')](_0x6829('0x1c'),_0x63f4c5);logger[_0x6829('0x14')](_0x6829('0x1c'),_0x63f4c5,JSON['stringify'](_0x32a932));_0x36253e(_0x32a932);})[_0x6829('0x1b')](function(_0x2c0d2c){logger['error'](_0x6829('0x1c'),_0x2c0d2c[_0x6829('0x19')],_0x63f4c5);_0x55dbe3(_0x1f4d36['error'](0x1f4,_0x2c0d2c[_0x6829('0x19')]));});});};exports[_0x6829('0x27')]=function(_0x28980e){var _0x3c0cb8=this;return new Promise(function(_0x529e82,_0x5d62e5){return db['VoiceQueueReport']['create'](_0x28980e[_0x6829('0x28')],{'raw':_0x28980e['options']?_0x28980e[_0x6829('0x1f')]['raw']===undefined?!![]:![]:!![]})[_0x6829('0x10')](function(_0x4bed89){logger['info'](_0x6829('0x27'),_0x28980e);logger[_0x6829('0x14')](_0x6829('0x27'),_0x28980e,JSON['stringify'](_0x4bed89));_0x529e82(_0x4bed89);})[_0x6829('0x1b')](function(_0x37ccbf){logger[_0x6829('0x17')]('CreateVoiceQueueReport',_0x37ccbf['message'],_0x28980e);_0x5d62e5(_0x3c0cb8[_0x6829('0x17')](0x1f4,_0x37ccbf[_0x6829('0x19')]));});});};exports[_0x6829('0x29')]=function(_0x3e6513){var _0x4a56a3=this;return new Promise(function(_0x48e5f8,_0x2d206e){return db[_0x6829('0x1d')][_0x6829('0x2a')](_0x3e6513[_0x6829('0x28')],{'raw':_0x3e6513[_0x6829('0x1f')]?_0x3e6513['options'][_0x6829('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3e6513[_0x6829('0x1f')]?_0x3e6513['options']['where']||null:null,'attributes':_0x3e6513['options']?_0x3e6513[_0x6829('0x1f')]['attributes']||null:null,'limit':_0x3e6513[_0x6829('0x1f')]?_0x3e6513[_0x6829('0x1f')][_0x6829('0x22')]||null:null})[_0x6829('0x10')](function(_0x29f84a){logger[_0x6829('0x11')](_0x6829('0x29'),_0x3e6513);logger[_0x6829('0x14')](_0x6829('0x29'),_0x3e6513,JSON[_0x6829('0x16')](_0x29f84a));_0x48e5f8(_0x29f84a);})['catch'](function(_0x47ebde){logger[_0x6829('0x17')](_0x6829('0x29'),_0x47ebde['message'],_0x3e6513);_0x2d206e(_0x4a56a3[_0x6829('0x17')](0x1f4,_0x47ebde['message']));});});};