Built motion from commit cb845558.|2.6.34
[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 _0x749a=['socket.io-emitter','./voiceQueueReport.socket','register','request','then','info','request\x20sent','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','VoiceQueueReport,\x20%s,\x20%s','result','GetVoiceQueueReport','VoiceQueueReport','options','where','include','model','attributes','map','debug','create','CreateVoiceQueueReport','catch','update','body','raw','limit','UpdateVoiceQueueReport','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost'];(function(_0x2895c8,_0x2ea5b5){var _0x3d8f05=function(_0x460119){while(--_0x460119){_0x2895c8['push'](_0x2895c8['shift']());}};_0x3d8f05(++_0x2ea5b5);}(_0x749a,0x14c));var _0xa749=function(_0x122ef9,_0x451d2a){_0x122ef9=_0x122ef9-0x0;var _0x42fba0=_0x749a[_0x122ef9];return _0x42fba0;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xa749('0x0'));var rs=require(_0xa749('0x1'));var fs=require('fs');var Redis=require(_0xa749('0x2'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xa749('0x3'))(_0xa749('0x4'));var config=require(_0xa749('0x5'));var jayson=require(_0xa749('0x6'));var client=jayson[_0xa749('0x7')][_0xa749('0x8')]({'port':0x232a});config[_0xa749('0x9')]=_[_0xa749('0xa')](config[_0xa749('0x9')],{'host':_0xa749('0xb'),'port':0x18eb});var socket=require(_0xa749('0xc'))(new Redis(config[_0xa749('0x9')]));require(_0xa749('0xd'))[_0xa749('0xe')](socket);function respondWithRpcPromise(_0x1f9083,_0x43b710,_0x28b1e7){return new BPromise(function(_0x2b1e69,_0x4e9c3c){return client[_0xa749('0xf')](_0x1f9083,_0x28b1e7)[_0xa749('0x10')](function(_0x4c1901){logger[_0xa749('0x11')]('VoiceQueueReport,\x20%s,\x20%s',_0x43b710,_0xa749('0x12'));logger['debug'](_0xa749('0x13'),_0x43b710,_0xa749('0x12'),JSON[_0xa749('0x14')](_0x4c1901));if(_0x4c1901[_0xa749('0x15')]){if(_0x4c1901[_0xa749('0x15')][_0xa749('0x16')]===0x1f4){logger[_0xa749('0x15')]('VoiceQueueReport,\x20%s,\x20%s',_0x43b710,_0x4c1901[_0xa749('0x15')][_0xa749('0x17')]);return _0x4e9c3c(_0x4c1901[_0xa749('0x15')]['message']);}logger[_0xa749('0x15')](_0xa749('0x18'),_0x43b710,_0x4c1901['error'][_0xa749('0x17')]);return _0x2b1e69(_0x4c1901[_0xa749('0x15')][_0xa749('0x17')]);}else{logger[_0xa749('0x11')](_0xa749('0x18'),_0x43b710,_0xa749('0x12'));_0x2b1e69(_0x4c1901[_0xa749('0x19')][_0xa749('0x17')]);}})['catch'](function(_0x2eeed5){logger[_0xa749('0x15')](_0xa749('0x18'),_0x43b710,_0x2eeed5);_0x4e9c3c(_0x2eeed5);});});}exports[_0xa749('0x1a')]=function(_0x5b550e){var _0x254fd1=this;return new Promise(function(_0x1ca82a,_0x2d41e1){return db[_0xa749('0x1b')]['findAll']({'raw':_0x5b550e[_0xa749('0x1c')]?_0x5b550e[_0xa749('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x5b550e[_0xa749('0x1c')]?_0x5b550e[_0xa749('0x1c')][_0xa749('0x1d')]||null:null,'attributes':_0x5b550e[_0xa749('0x1c')]?_0x5b550e['options']['attributes']||null:null,'limit':_0x5b550e[_0xa749('0x1c')]?_0x5b550e['options']['limit']||null:null,'include':_0x5b550e[_0xa749('0x1c')]?_0x5b550e[_0xa749('0x1c')][_0xa749('0x1e')]?_['map'](_0x5b550e[_0xa749('0x1c')]['include'],function(_0x1b4fec){return{'model':db[_0x1b4fec[_0xa749('0x1f')]],'as':_0x1b4fec['as'],'attributes':_0x1b4fec[_0xa749('0x20')],'include':_0x1b4fec['include']?_[_0xa749('0x21')](_0x1b4fec[_0xa749('0x1e')],function(_0x5b495e){return{'model':db[_0x5b495e[_0xa749('0x1f')]],'as':_0x5b495e['as'],'attributes':_0x5b495e[_0xa749('0x20')],'include':_0x5b495e[_0xa749('0x1e')]?_['map'](_0x5b495e[_0xa749('0x1e')],function(_0x1e9170){return{'model':db[_0x1e9170[_0xa749('0x1f')]],'as':_0x1e9170['as'],'attributes':_0x1e9170[_0xa749('0x20')]};}):[]};}):[]};}):[]:[]})[_0xa749('0x10')](function(_0x556536){logger[_0xa749('0x11')](_0xa749('0x1a'),_0x5b550e);logger[_0xa749('0x22')](_0xa749('0x1a'),_0x5b550e,JSON['stringify'](_0x556536));_0x1ca82a(_0x556536);})['catch'](function(_0x1e8722){logger[_0xa749('0x15')](_0xa749('0x1a'),_0x1e8722[_0xa749('0x17')],_0x5b550e);_0x2d41e1(_0x254fd1[_0xa749('0x15')](0x1f4,_0x1e8722[_0xa749('0x17')]));});});};exports['CreateVoiceQueueReport']=function(_0x14b5c3){var _0x421511=this;return new Promise(function(_0x2fe4ba,_0x2a244f){return db[_0xa749('0x1b')][_0xa749('0x23')](_0x14b5c3['body'],{'raw':_0x14b5c3[_0xa749('0x1c')]?_0x14b5c3[_0xa749('0x1c')]['raw']===undefined?!![]:![]:!![]})[_0xa749('0x10')](function(_0x3a2fff){logger[_0xa749('0x11')](_0xa749('0x24'),_0x14b5c3);logger['debug']('CreateVoiceQueueReport',_0x14b5c3,JSON[_0xa749('0x14')](_0x3a2fff));_0x2fe4ba(_0x3a2fff);})[_0xa749('0x25')](function(_0x23a5a7){logger[_0xa749('0x15')]('CreateVoiceQueueReport',_0x23a5a7['message'],_0x14b5c3);_0x2a244f(_0x421511[_0xa749('0x15')](0x1f4,_0x23a5a7[_0xa749('0x17')]));});});};exports['UpdateVoiceQueueReport']=function(_0x19cad6){var _0x4c1202=this;return new Promise(function(_0x84c1fe,_0x252ab0){return db[_0xa749('0x1b')][_0xa749('0x26')](_0x19cad6[_0xa749('0x27')],{'raw':_0x19cad6[_0xa749('0x1c')]?_0x19cad6[_0xa749('0x1c')][_0xa749('0x28')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x19cad6[_0xa749('0x1c')]?_0x19cad6[_0xa749('0x1c')][_0xa749('0x1d')]||null:null,'attributes':_0x19cad6[_0xa749('0x1c')]?_0x19cad6[_0xa749('0x1c')]['attributes']||null:null,'limit':_0x19cad6[_0xa749('0x1c')]?_0x19cad6[_0xa749('0x1c')][_0xa749('0x29')]||null:null})[_0xa749('0x10')](function(_0x38503d){logger['info']('UpdateVoiceQueueReport',_0x19cad6);logger[_0xa749('0x22')](_0xa749('0x2a'),_0x19cad6,JSON['stringify'](_0x38503d));_0x84c1fe(_0x38503d);})['catch'](function(_0x5ced24){logger[_0xa749('0x15')](_0xa749('0x2a'),_0x5ced24[_0xa749('0x17')],_0x19cad6);_0x252ab0(_0x4c1202[_0xa749('0x15')](0x1f4,_0x5ced24['message']));});});};