9893aa2cd814b049cd9cdb31eb74ffcc631325dc
[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 _0x5b00=['defaults','redis','socket.io-emitter','./voiceQueueReport.socket','register','request','then','info','VoiceQueueReport,\x20%s,\x20%s','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','error','message','result','GetVoiceQueueReport','findAll','options','raw','where','limit','include','map','model','attributes','CreateVoiceQueueReport','VoiceQueueReport','create','body','UpdateVoiceQueueReport','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http'];(function(_0x53358c,_0x35810d){var _0x10cfb8=function(_0x3dd2ce){while(--_0x3dd2ce){_0x53358c['push'](_0x53358c['shift']());}};_0x10cfb8(++_0x35810d);}(_0x5b00,0x1ee));var _0x05b0=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x5b00[_0x14add3];return _0x4a174f;};'use strict';var _=require(_0x05b0('0x0'));var util=require('util');var moment=require(_0x05b0('0x1'));var BPromise=require('bluebird');var rs=require(_0x05b0('0x2'));var fs=require('fs');var Redis=require(_0x05b0('0x3'));var db=require(_0x05b0('0x4'))['db'];var utils=require(_0x05b0('0x5'));var logger=require(_0x05b0('0x6'))(_0x05b0('0x7'));var config=require('../../config/environment');var jayson=require(_0x05b0('0x8'));var client=jayson['client'][_0x05b0('0x9')]({'port':0x232a});config['redis']=_[_0x05b0('0xa')](config[_0x05b0('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0x05b0('0xc'))(new Redis(config['redis']));require(_0x05b0('0xd'))[_0x05b0('0xe')](socket);function respondWithRpcPromise(_0x59407c,_0x460a87,_0x505fa2){return new BPromise(function(_0x29c52a,_0x3ba3db){return client[_0x05b0('0xf')](_0x59407c,_0x505fa2)[_0x05b0('0x10')](function(_0x2b84e8){logger[_0x05b0('0x11')](_0x05b0('0x12'),_0x460a87,'request\x20sent');logger[_0x05b0('0x13')](_0x05b0('0x14'),_0x460a87,_0x05b0('0x15'),JSON[_0x05b0('0x16')](_0x2b84e8));if(_0x2b84e8['error']){if(_0x2b84e8['error'][_0x05b0('0x17')]===0x1f4){logger[_0x05b0('0x18')](_0x05b0('0x12'),_0x460a87,_0x2b84e8['error'][_0x05b0('0x19')]);return _0x3ba3db(_0x2b84e8[_0x05b0('0x18')][_0x05b0('0x19')]);}logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0x460a87,_0x2b84e8['error']['message']);return _0x29c52a(_0x2b84e8[_0x05b0('0x18')]['message']);}else{logger[_0x05b0('0x11')]('VoiceQueueReport,\x20%s,\x20%s',_0x460a87,'request\x20sent');_0x29c52a(_0x2b84e8[_0x05b0('0x1a')][_0x05b0('0x19')]);}})['catch'](function(_0x3b1266){logger[_0x05b0('0x18')](_0x05b0('0x12'),_0x460a87,_0x3b1266);_0x3ba3db(_0x3b1266);});});}exports[_0x05b0('0x1b')]=function(_0x53c5b4){var _0x4e014b=this;return new Promise(function(_0x184a42,_0x3fef35){return db['VoiceQueueReport'][_0x05b0('0x1c')]({'raw':_0x53c5b4[_0x05b0('0x1d')]?_0x53c5b4[_0x05b0('0x1d')][_0x05b0('0x1e')]===undefined?!![]:![]:!![],'where':_0x53c5b4[_0x05b0('0x1d')]?_0x53c5b4['options'][_0x05b0('0x1f')]||null:null,'attributes':_0x53c5b4[_0x05b0('0x1d')]?_0x53c5b4[_0x05b0('0x1d')]['attributes']||null:null,'limit':_0x53c5b4[_0x05b0('0x1d')]?_0x53c5b4[_0x05b0('0x1d')][_0x05b0('0x20')]||null:null,'include':_0x53c5b4[_0x05b0('0x1d')]?_0x53c5b4[_0x05b0('0x1d')][_0x05b0('0x21')]?_[_0x05b0('0x22')](_0x53c5b4[_0x05b0('0x1d')][_0x05b0('0x21')],function(_0x24e456){return{'model':db[_0x24e456[_0x05b0('0x23')]],'as':_0x24e456['as'],'attributes':_0x24e456[_0x05b0('0x24')],'include':_0x24e456[_0x05b0('0x21')]?_[_0x05b0('0x22')](_0x24e456[_0x05b0('0x21')],function(_0x3bc054){return{'model':db[_0x3bc054[_0x05b0('0x23')]],'as':_0x3bc054['as'],'attributes':_0x3bc054[_0x05b0('0x24')],'include':_0x3bc054['include']?_['map'](_0x3bc054[_0x05b0('0x21')],function(_0xb52b7f){return{'model':db[_0xb52b7f[_0x05b0('0x23')]],'as':_0xb52b7f['as'],'attributes':_0xb52b7f[_0x05b0('0x24')]};}):[]};}):[]};}):[]:[]})[_0x05b0('0x10')](function(_0x5a2b09){logger[_0x05b0('0x11')](_0x05b0('0x1b'),_0x53c5b4);logger[_0x05b0('0x13')](_0x05b0('0x1b'),_0x53c5b4,JSON[_0x05b0('0x16')](_0x5a2b09));_0x184a42(_0x5a2b09);})['catch'](function(_0x140fb0){logger[_0x05b0('0x18')](_0x05b0('0x1b'),_0x140fb0[_0x05b0('0x19')],_0x53c5b4);_0x3fef35(_0x4e014b[_0x05b0('0x18')](0x1f4,_0x140fb0[_0x05b0('0x19')]));});});};exports[_0x05b0('0x25')]=function(_0x3d4a7){var _0x367817=this;return new Promise(function(_0x2f31d4,_0x4541c6){return db[_0x05b0('0x26')][_0x05b0('0x27')](_0x3d4a7[_0x05b0('0x28')],{'raw':_0x3d4a7['options']?_0x3d4a7[_0x05b0('0x1d')][_0x05b0('0x1e')]===undefined?!![]:![]:!![]})[_0x05b0('0x10')](function(_0x471e73){logger[_0x05b0('0x11')]('CreateVoiceQueueReport',_0x3d4a7);logger['debug']('CreateVoiceQueueReport',_0x3d4a7,JSON['stringify'](_0x471e73));_0x2f31d4(_0x471e73);})['catch'](function(_0x322468){logger[_0x05b0('0x18')]('CreateVoiceQueueReport',_0x322468[_0x05b0('0x19')],_0x3d4a7);_0x4541c6(_0x367817[_0x05b0('0x18')](0x1f4,_0x322468['message']));});});};exports[_0x05b0('0x29')]=function(_0x2704ec){var _0x3d4add=this;return new Promise(function(_0x5a4c0c,_0x408003){return db[_0x05b0('0x26')]['update'](_0x2704ec[_0x05b0('0x28')],{'raw':_0x2704ec['options']?_0x2704ec[_0x05b0('0x1d')][_0x05b0('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2704ec[_0x05b0('0x1d')]?_0x2704ec[_0x05b0('0x1d')][_0x05b0('0x1f')]||null:null,'attributes':_0x2704ec['options']?_0x2704ec[_0x05b0('0x1d')][_0x05b0('0x24')]||null:null,'limit':_0x2704ec['options']?_0x2704ec['options'][_0x05b0('0x20')]||null:null})[_0x05b0('0x10')](function(_0x19eeb8){logger[_0x05b0('0x11')](_0x05b0('0x29'),_0x2704ec);logger['debug'](_0x05b0('0x29'),_0x2704ec,JSON[_0x05b0('0x16')](_0x19eeb8));_0x5a4c0c(_0x19eeb8);})['catch'](function(_0x4859cc){logger['error']('UpdateVoiceQueueReport',_0x4859cc[_0x05b0('0x19')],_0x2704ec);_0x408003(_0x3d4add['error'](0x1f4,_0x4859cc[_0x05b0('0x19')]));});});};