d8cabe45a9393e245b9772589167806228a554f9
[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 _0x8343=['where','attributes','limit','include','map','model','stringify','CreateVoiceQueueReport','body','then','UpdateVoiceQueueReport','update','raw','lodash','util','moment','randomstring','ioredis','../../config/utils','jayson/promise','client','http','redis','socket.io-emitter','./voiceQueueReport.socket','register','request','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','error','code','message','catch','GetVoiceQueueReport','VoiceQueueReport','findAll','options'];(function(_0xb23c05,_0xbb6c8a){var _0xde8542=function(_0x4c096d){while(--_0x4c096d){_0xb23c05['push'](_0xb23c05['shift']());}};_0xde8542(++_0xbb6c8a);}(_0x8343,0x175));var _0x3834=function(_0x2af95d,_0xd602d6){_0x2af95d=_0x2af95d-0x0;var _0x17c87b=_0x8343[_0x2af95d];return _0x17c87b;};'use strict';var _=require(_0x3834('0x0'));var util=require(_0x3834('0x1'));var moment=require(_0x3834('0x2'));var BPromise=require('bluebird');var rs=require(_0x3834('0x3'));var fs=require('fs');var Redis=require(_0x3834('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x3834('0x5'));var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require(_0x3834('0x6'));var client=jayson[_0x3834('0x7')][_0x3834('0x8')]({'port':0x232a});config[_0x3834('0x9')]=_['defaults'](config[_0x3834('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x3834('0xa'))(new Redis(config[_0x3834('0x9')]));require(_0x3834('0xb'))[_0x3834('0xc')](socket);function respondWithRpcPromise(_0x28ea6c,_0x1e0031,_0x3fa76c){return new BPromise(function(_0xf1b549,_0x448182){return client[_0x3834('0xd')](_0x28ea6c,_0x3fa76c)['then'](function(_0x1ae1cb){logger[_0x3834('0xe')](_0x3834('0xf'),_0x1e0031,_0x3834('0x10'));logger[_0x3834('0x11')](_0x3834('0x12'),_0x1e0031,_0x3834('0x10'),JSON['stringify'](_0x1ae1cb));if(_0x1ae1cb[_0x3834('0x13')]){if(_0x1ae1cb[_0x3834('0x13')][_0x3834('0x14')]===0x1f4){logger[_0x3834('0x13')]('VoiceQueueReport,\x20%s,\x20%s',_0x1e0031,_0x1ae1cb['error'][_0x3834('0x15')]);return _0x448182(_0x1ae1cb[_0x3834('0x13')][_0x3834('0x15')]);}logger[_0x3834('0x13')](_0x3834('0xf'),_0x1e0031,_0x1ae1cb[_0x3834('0x13')][_0x3834('0x15')]);return _0xf1b549(_0x1ae1cb[_0x3834('0x13')]['message']);}else{logger[_0x3834('0xe')]('VoiceQueueReport,\x20%s,\x20%s',_0x1e0031,_0x3834('0x10'));_0xf1b549(_0x1ae1cb['result'][_0x3834('0x15')]);}})[_0x3834('0x16')](function(_0x36c51f){logger[_0x3834('0x13')](_0x3834('0xf'),_0x1e0031,_0x36c51f);_0x448182(_0x36c51f);});});}exports[_0x3834('0x17')]=function(_0x32d848){var _0x315b8f=this;return new Promise(function(_0x492bec,_0x53aaa3){return db[_0x3834('0x18')][_0x3834('0x19')]({'raw':_0x32d848[_0x3834('0x1a')]?_0x32d848['options']['raw']===undefined?!![]:![]:!![],'where':_0x32d848['options']?_0x32d848['options'][_0x3834('0x1b')]||null:null,'attributes':_0x32d848['options']?_0x32d848[_0x3834('0x1a')][_0x3834('0x1c')]||null:null,'limit':_0x32d848[_0x3834('0x1a')]?_0x32d848['options'][_0x3834('0x1d')]||null:null,'include':_0x32d848[_0x3834('0x1a')]?_0x32d848['options'][_0x3834('0x1e')]?_[_0x3834('0x1f')](_0x32d848['options'][_0x3834('0x1e')],function(_0x171862){return{'model':db[_0x171862[_0x3834('0x20')]],'as':_0x171862['as'],'attributes':_0x171862[_0x3834('0x1c')],'include':_0x171862['include']?_[_0x3834('0x1f')](_0x171862[_0x3834('0x1e')],function(_0x1d1022){return{'model':db[_0x1d1022[_0x3834('0x20')]],'as':_0x1d1022['as'],'attributes':_0x1d1022[_0x3834('0x1c')],'include':_0x1d1022[_0x3834('0x1e')]?_['map'](_0x1d1022[_0x3834('0x1e')],function(_0x77a2bd){return{'model':db[_0x77a2bd['model']],'as':_0x77a2bd['as'],'attributes':_0x77a2bd[_0x3834('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2b8652){logger[_0x3834('0xe')](_0x3834('0x17'),_0x32d848);logger['debug']('GetVoiceQueueReport',_0x32d848,JSON[_0x3834('0x21')](_0x2b8652));_0x492bec(_0x2b8652);})['catch'](function(_0x432b4c){logger[_0x3834('0x13')](_0x3834('0x17'),_0x432b4c['message'],_0x32d848);_0x53aaa3(_0x315b8f[_0x3834('0x13')](0x1f4,_0x432b4c[_0x3834('0x15')]));});});};exports[_0x3834('0x22')]=function(_0x38dcc4){var _0x555d43=this;return new Promise(function(_0x120594,_0x1f0168){return db['VoiceQueueReport']['create'](_0x38dcc4[_0x3834('0x23')],{'raw':_0x38dcc4['options']?_0x38dcc4['options']['raw']===undefined?!![]:![]:!![]})[_0x3834('0x24')](function(_0x28352f){logger[_0x3834('0xe')](_0x3834('0x22'),_0x38dcc4);logger[_0x3834('0x11')](_0x3834('0x22'),_0x38dcc4,JSON[_0x3834('0x21')](_0x28352f));_0x120594(_0x28352f);})[_0x3834('0x16')](function(_0x3d01ae){logger[_0x3834('0x13')](_0x3834('0x22'),_0x3d01ae[_0x3834('0x15')],_0x38dcc4);_0x1f0168(_0x555d43[_0x3834('0x13')](0x1f4,_0x3d01ae[_0x3834('0x15')]));});});};exports[_0x3834('0x25')]=function(_0x1cfce1){var _0x49a17a=this;return new Promise(function(_0x3570a5,_0x3a7770){return db['VoiceQueueReport'][_0x3834('0x26')](_0x1cfce1[_0x3834('0x23')],{'raw':_0x1cfce1[_0x3834('0x1a')]?_0x1cfce1['options'][_0x3834('0x27')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1cfce1[_0x3834('0x1a')]?_0x1cfce1['options'][_0x3834('0x1b')]||null:null,'attributes':_0x1cfce1['options']?_0x1cfce1[_0x3834('0x1a')]['attributes']||null:null,'limit':_0x1cfce1[_0x3834('0x1a')]?_0x1cfce1[_0x3834('0x1a')][_0x3834('0x1d')]||null:null})[_0x3834('0x24')](function(_0x1f4357){logger[_0x3834('0xe')](_0x3834('0x25'),_0x1cfce1);logger[_0x3834('0x11')](_0x3834('0x25'),_0x1cfce1,JSON[_0x3834('0x21')](_0x1f4357));_0x3570a5(_0x1f4357);})[_0x3834('0x16')](function(_0x354078){logger[_0x3834('0x13')](_0x3834('0x25'),_0x354078[_0x3834('0x15')],_0x1cfce1);_0x3a7770(_0x49a17a['error'](0x1f4,_0x354078[_0x3834('0x15')]));});});};