58668b9abfcaff31259eb7d2e8a527f6d5146040
[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 _0x74a9=['attributes','limit','include','map','model','then','GetVoiceQueueReport','create','body','raw','debug','CreateVoiceQueueReport','update','UpdateVoiceQueueReport','lodash','moment','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./voiceQueueReport.socket','register','request','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','stringify','code','error','message','result','catch','VoiceQueueReport','findAll','options','where'];(function(_0x4e7d25,_0x58285f){var _0x526fe6=function(_0x4f0aec){while(--_0x4f0aec){_0x4e7d25['push'](_0x4e7d25['shift']());}};_0x526fe6(++_0x58285f);}(_0x74a9,0x188));var _0x974a=function(_0x3c4087,_0x5c764b){_0x3c4087=_0x3c4087-0x0;var _0x23ad1f=_0x74a9[_0x3c4087];return _0x23ad1f;};'use strict';var _=require(_0x974a('0x0'));var util=require('util');var moment=require(_0x974a('0x1'));var BPromise=require('bluebird');var rs=require(_0x974a('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x974a('0x3'))['db'];var utils=require(_0x974a('0x4'));var logger=require('../../config/logger')(_0x974a('0x5'));var config=require(_0x974a('0x6'));var jayson=require(_0x974a('0x7'));var client=jayson[_0x974a('0x8')][_0x974a('0x9')]({'port':0x232a});config[_0x974a('0xa')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x974a('0xb'))(new Redis(config[_0x974a('0xa')]));require(_0x974a('0xc'))[_0x974a('0xd')](socket);function respondWithRpcPromise(_0x47b909,_0xf290af,_0x112832){return new BPromise(function(_0x2679ce,_0x370b9b){return client[_0x974a('0xe')](_0x47b909,_0x112832)['then'](function(_0x3af198){logger[_0x974a('0xf')](_0x974a('0x10'),_0xf290af,_0x974a('0x11'));logger['debug']('VoiceQueueReport,\x20%s,\x20%s,\x20%s',_0xf290af,_0x974a('0x11'),JSON[_0x974a('0x12')](_0x3af198));if(_0x3af198['error']){if(_0x3af198['error'][_0x974a('0x13')]===0x1f4){logger[_0x974a('0x14')]('VoiceQueueReport,\x20%s,\x20%s',_0xf290af,_0x3af198[_0x974a('0x14')][_0x974a('0x15')]);return _0x370b9b(_0x3af198[_0x974a('0x14')][_0x974a('0x15')]);}logger[_0x974a('0x14')](_0x974a('0x10'),_0xf290af,_0x3af198[_0x974a('0x14')][_0x974a('0x15')]);return _0x2679ce(_0x3af198[_0x974a('0x14')][_0x974a('0x15')]);}else{logger[_0x974a('0xf')](_0x974a('0x10'),_0xf290af,_0x974a('0x11'));_0x2679ce(_0x3af198[_0x974a('0x16')][_0x974a('0x15')]);}})[_0x974a('0x17')](function(_0x45157d){logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0xf290af,_0x45157d);_0x370b9b(_0x45157d);});});}exports['GetVoiceQueueReport']=function(_0x578e18){var _0x34d36e=this;return new Promise(function(_0x3cdc89,_0xf75d02){return db[_0x974a('0x18')][_0x974a('0x19')]({'raw':_0x578e18[_0x974a('0x1a')]?_0x578e18[_0x974a('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x578e18['options']?_0x578e18['options'][_0x974a('0x1b')]||null:null,'attributes':_0x578e18[_0x974a('0x1a')]?_0x578e18[_0x974a('0x1a')][_0x974a('0x1c')]||null:null,'limit':_0x578e18['options']?_0x578e18[_0x974a('0x1a')][_0x974a('0x1d')]||null:null,'include':_0x578e18['options']?_0x578e18[_0x974a('0x1a')][_0x974a('0x1e')]?_[_0x974a('0x1f')](_0x578e18[_0x974a('0x1a')][_0x974a('0x1e')],function(_0x523884){return{'model':db[_0x523884[_0x974a('0x20')]],'as':_0x523884['as'],'attributes':_0x523884[_0x974a('0x1c')],'include':_0x523884[_0x974a('0x1e')]?_['map'](_0x523884['include'],function(_0xd65bc6){return{'model':db[_0xd65bc6[_0x974a('0x20')]],'as':_0xd65bc6['as'],'attributes':_0xd65bc6[_0x974a('0x1c')],'include':_0xd65bc6[_0x974a('0x1e')]?_[_0x974a('0x1f')](_0xd65bc6['include'],function(_0x44d50a){return{'model':db[_0x44d50a['model']],'as':_0x44d50a['as'],'attributes':_0x44d50a[_0x974a('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x974a('0x21')](function(_0x3bc683){logger[_0x974a('0xf')](_0x974a('0x22'),_0x578e18);logger['debug'](_0x974a('0x22'),_0x578e18,JSON[_0x974a('0x12')](_0x3bc683));_0x3cdc89(_0x3bc683);})[_0x974a('0x17')](function(_0x35330c){logger[_0x974a('0x14')](_0x974a('0x22'),_0x35330c[_0x974a('0x15')],_0x578e18);_0xf75d02(_0x34d36e[_0x974a('0x14')](0x1f4,_0x35330c[_0x974a('0x15')]));});});};exports['CreateVoiceQueueReport']=function(_0x1e354d){var _0x2ca45c=this;return new Promise(function(_0x31429c,_0x2dfcbb){return db['VoiceQueueReport'][_0x974a('0x23')](_0x1e354d[_0x974a('0x24')],{'raw':_0x1e354d['options']?_0x1e354d[_0x974a('0x1a')][_0x974a('0x25')]===undefined?!![]:![]:!![]})['then'](function(_0x2b5659){logger[_0x974a('0xf')]('CreateVoiceQueueReport',_0x1e354d);logger[_0x974a('0x26')](_0x974a('0x27'),_0x1e354d,JSON['stringify'](_0x2b5659));_0x31429c(_0x2b5659);})[_0x974a('0x17')](function(_0x282736){logger[_0x974a('0x14')](_0x974a('0x27'),_0x282736[_0x974a('0x15')],_0x1e354d);_0x2dfcbb(_0x2ca45c['error'](0x1f4,_0x282736['message']));});});};exports['UpdateVoiceQueueReport']=function(_0x727aa0){var _0x331ddc=this;return new Promise(function(_0x302b45,_0x3b8dbe){return db[_0x974a('0x18')][_0x974a('0x28')](_0x727aa0[_0x974a('0x24')],{'raw':_0x727aa0[_0x974a('0x1a')]?_0x727aa0['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x727aa0[_0x974a('0x1a')]?_0x727aa0['options'][_0x974a('0x1b')]||null:null,'attributes':_0x727aa0['options']?_0x727aa0[_0x974a('0x1a')]['attributes']||null:null,'limit':_0x727aa0['options']?_0x727aa0['options'][_0x974a('0x1d')]||null:null})['then'](function(_0x120e7e){logger[_0x974a('0xf')](_0x974a('0x29'),_0x727aa0);logger['debug'](_0x974a('0x29'),_0x727aa0,JSON['stringify'](_0x120e7e));_0x302b45(_0x120e7e);})[_0x974a('0x17')](function(_0x24b59f){logger[_0x974a('0x14')](_0x974a('0x29'),_0x24b59f['message'],_0x727aa0);_0x3b8dbe(_0x331ddc[_0x974a('0x14')](0x1f4,_0x24b59f[_0x974a('0x15')]));});});};