Built motion from commit da617fac.|2.6.6
[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 _0xca2e=['jayson/promise','client','http','redis','socket.io-emitter','./voiceQueueReport.socket','register','then','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','VoiceQueueReport','findAll','options','raw','attributes','limit','include','model','map','GetVoiceQueueReport','CreateVoiceQueueReport','create','body','info','UpdateVoiceQueueReport','update','where','lodash','moment','bluebird','randomstring','../../config/logger','rpc','../../config/environment'];(function(_0x490c64,_0x8a5cb4){var _0x32111a=function(_0x1e7b24){while(--_0x1e7b24){_0x490c64['push'](_0x490c64['shift']());}};_0x32111a(++_0x8a5cb4);}(_0xca2e,0x1bc));var _0xeca2=function(_0x551fb4,_0x477b9c){_0x551fb4=_0x551fb4-0x0;var _0x23e596=_0xca2e[_0x551fb4];return _0x23e596;};'use strict';var _=require(_0xeca2('0x0'));var util=require('util');var moment=require(_0xeca2('0x1'));var BPromise=require(_0xeca2('0x2'));var rs=require(_0xeca2('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xeca2('0x4'))(_0xeca2('0x5'));var config=require(_0xeca2('0x6'));var jayson=require(_0xeca2('0x7'));var client=jayson[_0xeca2('0x8')][_0xeca2('0x9')]({'port':0x232a});config[_0xeca2('0xa')]=_['defaults'](config[_0xeca2('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xeca2('0xb'))(new Redis(config[_0xeca2('0xa')]));require(_0xeca2('0xc'))[_0xeca2('0xd')](socket);function respondWithRpcPromise(_0x1a4e4c,_0x1bb86d,_0x257402){return new BPromise(function(_0x3941da,_0x378206){return client['request'](_0x1a4e4c,_0x257402)[_0xeca2('0xe')](function(_0x133a74){logger['info'](_0xeca2('0xf'),_0x1bb86d,_0xeca2('0x10'));logger['debug'](_0xeca2('0x11'),_0x1bb86d,_0xeca2('0x10'),JSON[_0xeca2('0x12')](_0x133a74));if(_0x133a74[_0xeca2('0x13')]){if(_0x133a74['error'][_0xeca2('0x14')]===0x1f4){logger[_0xeca2('0x13')](_0xeca2('0xf'),_0x1bb86d,_0x133a74[_0xeca2('0x13')][_0xeca2('0x15')]);return _0x378206(_0x133a74[_0xeca2('0x13')][_0xeca2('0x15')]);}logger[_0xeca2('0x13')](_0xeca2('0xf'),_0x1bb86d,_0x133a74[_0xeca2('0x13')]['message']);return _0x3941da(_0x133a74[_0xeca2('0x13')][_0xeca2('0x15')]);}else{logger['info'](_0xeca2('0xf'),_0x1bb86d,'request\x20sent');_0x3941da(_0x133a74[_0xeca2('0x16')]['message']);}})[_0xeca2('0x17')](function(_0x4cbdd1){logger[_0xeca2('0x13')](_0xeca2('0xf'),_0x1bb86d,_0x4cbdd1);_0x378206(_0x4cbdd1);});});}exports['GetVoiceQueueReport']=function(_0x55ae0b){var _0x394db8=this;return new Promise(function(_0x48621c,_0x53bb79){return db[_0xeca2('0x18')][_0xeca2('0x19')]({'raw':_0x55ae0b[_0xeca2('0x1a')]?_0x55ae0b[_0xeca2('0x1a')][_0xeca2('0x1b')]===undefined?!![]:![]:!![],'where':_0x55ae0b[_0xeca2('0x1a')]?_0x55ae0b[_0xeca2('0x1a')]['where']||null:null,'attributes':_0x55ae0b[_0xeca2('0x1a')]?_0x55ae0b['options'][_0xeca2('0x1c')]||null:null,'limit':_0x55ae0b[_0xeca2('0x1a')]?_0x55ae0b['options'][_0xeca2('0x1d')]||null:null,'include':_0x55ae0b[_0xeca2('0x1a')]?_0x55ae0b[_0xeca2('0x1a')][_0xeca2('0x1e')]?_['map'](_0x55ae0b[_0xeca2('0x1a')][_0xeca2('0x1e')],function(_0x50fe45){return{'model':db[_0x50fe45[_0xeca2('0x1f')]],'as':_0x50fe45['as'],'attributes':_0x50fe45[_0xeca2('0x1c')],'include':_0x50fe45[_0xeca2('0x1e')]?_['map'](_0x50fe45[_0xeca2('0x1e')],function(_0x46bf45){return{'model':db[_0x46bf45[_0xeca2('0x1f')]],'as':_0x46bf45['as'],'attributes':_0x46bf45[_0xeca2('0x1c')],'include':_0x46bf45[_0xeca2('0x1e')]?_[_0xeca2('0x20')](_0x46bf45[_0xeca2('0x1e')],function(_0x29b69b){return{'model':db[_0x29b69b['model']],'as':_0x29b69b['as'],'attributes':_0x29b69b[_0xeca2('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xeca2('0xe')](function(_0x8d70b8){logger['info']('GetVoiceQueueReport',_0x55ae0b);logger['debug'](_0xeca2('0x21'),_0x55ae0b,JSON['stringify'](_0x8d70b8));_0x48621c(_0x8d70b8);})[_0xeca2('0x17')](function(_0x27e73b){logger['error'](_0xeca2('0x21'),_0x27e73b['message'],_0x55ae0b);_0x53bb79(_0x394db8[_0xeca2('0x13')](0x1f4,_0x27e73b['message']));});});};exports[_0xeca2('0x22')]=function(_0x29bf1c){var _0x2b8f96=this;return new Promise(function(_0x17c748,_0x4f6e08){return db[_0xeca2('0x18')][_0xeca2('0x23')](_0x29bf1c[_0xeca2('0x24')],{'raw':_0x29bf1c[_0xeca2('0x1a')]?_0x29bf1c[_0xeca2('0x1a')][_0xeca2('0x1b')]===undefined?!![]:![]:!![]})[_0xeca2('0xe')](function(_0x3fd600){logger[_0xeca2('0x25')](_0xeca2('0x22'),_0x29bf1c);logger['debug'](_0xeca2('0x22'),_0x29bf1c,JSON[_0xeca2('0x12')](_0x3fd600));_0x17c748(_0x3fd600);})['catch'](function(_0x1bf619){logger[_0xeca2('0x13')](_0xeca2('0x22'),_0x1bf619['message'],_0x29bf1c);_0x4f6e08(_0x2b8f96['error'](0x1f4,_0x1bf619[_0xeca2('0x15')]));});});};exports[_0xeca2('0x26')]=function(_0x1584df){var _0x3927e2=this;return new Promise(function(_0x8fef9e,_0x5c6721){return db[_0xeca2('0x18')][_0xeca2('0x27')](_0x1584df['body'],{'raw':_0x1584df['options']?_0x1584df[_0xeca2('0x1a')][_0xeca2('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1584df[_0xeca2('0x1a')]?_0x1584df['options'][_0xeca2('0x28')]||null:null,'attributes':_0x1584df[_0xeca2('0x1a')]?_0x1584df[_0xeca2('0x1a')][_0xeca2('0x1c')]||null:null,'limit':_0x1584df['options']?_0x1584df['options'][_0xeca2('0x1d')]||null:null})['then'](function(_0x3fbdbb){logger[_0xeca2('0x25')]('UpdateVoiceQueueReport',_0x1584df);logger['debug']('UpdateVoiceQueueReport',_0x1584df,JSON['stringify'](_0x3fbdbb));_0x8fef9e(_0x3fbdbb);})[_0xeca2('0x17')](function(_0x9c25b0){logger['error'](_0xeca2('0x26'),_0x9c25b0['message'],_0x1584df);_0x5c6721(_0x3927e2['error'](0x1f4,_0x9c25b0[_0xeca2('0x15')]));});});};