c4a898823fbce3bfad70ace7e113f9a079ad26c3
[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 _0x60a3=['body','UpdateVoiceQueueReport','update','lodash','util','moment','bluebird','../../config/utils','../../config/logger','rpc','../../config/environment','http','defaults','redis','localhost','socket.io-emitter','./voiceQueueReport.socket','register','then','info','VoiceQueueReport,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','GetVoiceQueueReport','findAll','options','raw','where','limit','map','include','model','attributes','CreateVoiceQueueReport','VoiceQueueReport','create'];(function(_0x42d551,_0x550d13){var _0x4db0ac=function(_0x5f420d){while(--_0x5f420d){_0x42d551['push'](_0x42d551['shift']());}};_0x4db0ac(++_0x550d13);}(_0x60a3,0x1d1));var _0x360a=function(_0x2453ee,_0x5b49c5){_0x2453ee=_0x2453ee-0x0;var _0x339005=_0x60a3[_0x2453ee];return _0x339005;};'use strict';var _=require(_0x360a('0x0'));var util=require(_0x360a('0x1'));var moment=require(_0x360a('0x2'));var BPromise=require(_0x360a('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x360a('0x4'));var logger=require(_0x360a('0x5'))(_0x360a('0x6'));var config=require(_0x360a('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0x360a('0x8')]({'port':0x232a});config['redis']=_[_0x360a('0x9')](config[_0x360a('0xa')],{'host':_0x360a('0xb'),'port':0x18eb});var socket=require(_0x360a('0xc'))(new Redis(config['redis']));require(_0x360a('0xd'))[_0x360a('0xe')](socket);function respondWithRpcPromise(_0x2e0244,_0x4b9758,_0xda7d4c){return new BPromise(function(_0x3d00b7,_0x400f64){return client['request'](_0x2e0244,_0xda7d4c)[_0x360a('0xf')](function(_0x24f8d6){logger[_0x360a('0x10')](_0x360a('0x11'),_0x4b9758,'request\x20sent');logger[_0x360a('0x12')]('VoiceQueueReport,\x20%s,\x20%s,\x20%s',_0x4b9758,_0x360a('0x13'),JSON[_0x360a('0x14')](_0x24f8d6));if(_0x24f8d6[_0x360a('0x15')]){if(_0x24f8d6['error'][_0x360a('0x16')]===0x1f4){logger[_0x360a('0x15')](_0x360a('0x11'),_0x4b9758,_0x24f8d6['error'][_0x360a('0x17')]);return _0x400f64(_0x24f8d6[_0x360a('0x15')]['message']);}logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0x4b9758,_0x24f8d6[_0x360a('0x15')][_0x360a('0x17')]);return _0x3d00b7(_0x24f8d6[_0x360a('0x15')][_0x360a('0x17')]);}else{logger[_0x360a('0x10')]('VoiceQueueReport,\x20%s,\x20%s',_0x4b9758,'request\x20sent');_0x3d00b7(_0x24f8d6[_0x360a('0x18')][_0x360a('0x17')]);}})[_0x360a('0x19')](function(_0x164d28){logger['error'](_0x360a('0x11'),_0x4b9758,_0x164d28);_0x400f64(_0x164d28);});});}exports[_0x360a('0x1a')]=function(_0x26cb6f){var _0x13bbc8=this;return new Promise(function(_0x316a31,_0x2d6619){return db['VoiceQueueReport'][_0x360a('0x1b')]({'raw':_0x26cb6f['options']?_0x26cb6f[_0x360a('0x1c')][_0x360a('0x1d')]===undefined?!![]:![]:!![],'where':_0x26cb6f[_0x360a('0x1c')]?_0x26cb6f[_0x360a('0x1c')][_0x360a('0x1e')]||null:null,'attributes':_0x26cb6f[_0x360a('0x1c')]?_0x26cb6f[_0x360a('0x1c')]['attributes']||null:null,'limit':_0x26cb6f['options']?_0x26cb6f[_0x360a('0x1c')][_0x360a('0x1f')]||null:null,'include':_0x26cb6f[_0x360a('0x1c')]?_0x26cb6f[_0x360a('0x1c')]['include']?_[_0x360a('0x20')](_0x26cb6f['options'][_0x360a('0x21')],function(_0x26bf30){return{'model':db[_0x26bf30[_0x360a('0x22')]],'as':_0x26bf30['as'],'attributes':_0x26bf30[_0x360a('0x23')],'include':_0x26bf30[_0x360a('0x21')]?_[_0x360a('0x20')](_0x26bf30[_0x360a('0x21')],function(_0x35cbd6){return{'model':db[_0x35cbd6[_0x360a('0x22')]],'as':_0x35cbd6['as'],'attributes':_0x35cbd6['attributes'],'include':_0x35cbd6[_0x360a('0x21')]?_['map'](_0x35cbd6[_0x360a('0x21')],function(_0x576e77){return{'model':db[_0x576e77['model']],'as':_0x576e77['as'],'attributes':_0x576e77[_0x360a('0x23')]};}):[]};}):[]};}):[]:[]})[_0x360a('0xf')](function(_0x45fa1c){logger[_0x360a('0x10')](_0x360a('0x1a'),_0x26cb6f);logger[_0x360a('0x12')](_0x360a('0x1a'),_0x26cb6f,JSON[_0x360a('0x14')](_0x45fa1c));_0x316a31(_0x45fa1c);})[_0x360a('0x19')](function(_0x50bb62){logger[_0x360a('0x15')](_0x360a('0x1a'),_0x50bb62[_0x360a('0x17')],_0x26cb6f);_0x2d6619(_0x13bbc8[_0x360a('0x15')](0x1f4,_0x50bb62[_0x360a('0x17')]));});});};exports[_0x360a('0x24')]=function(_0x21f9fa){var _0x133d07=this;return new Promise(function(_0x33ba93,_0x21fd76){return db[_0x360a('0x25')][_0x360a('0x26')](_0x21f9fa[_0x360a('0x27')],{'raw':_0x21f9fa['options']?_0x21f9fa['options']['raw']===undefined?!![]:![]:!![]})['then'](function(_0x5c3e34){logger['info'](_0x360a('0x24'),_0x21f9fa);logger[_0x360a('0x12')](_0x360a('0x24'),_0x21f9fa,JSON['stringify'](_0x5c3e34));_0x33ba93(_0x5c3e34);})[_0x360a('0x19')](function(_0x4b4b43){logger[_0x360a('0x15')]('CreateVoiceQueueReport',_0x4b4b43[_0x360a('0x17')],_0x21f9fa);_0x21fd76(_0x133d07['error'](0x1f4,_0x4b4b43[_0x360a('0x17')]));});});};exports[_0x360a('0x28')]=function(_0x488560){var _0x283cf6=this;return new Promise(function(_0x136e33,_0x5a6f0e){return db[_0x360a('0x25')][_0x360a('0x29')](_0x488560[_0x360a('0x27')],{'raw':_0x488560['options']?_0x488560[_0x360a('0x1c')][_0x360a('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x488560['options']?_0x488560[_0x360a('0x1c')][_0x360a('0x1e')]||null:null,'attributes':_0x488560[_0x360a('0x1c')]?_0x488560[_0x360a('0x1c')]['attributes']||null:null,'limit':_0x488560[_0x360a('0x1c')]?_0x488560['options'][_0x360a('0x1f')]||null:null})[_0x360a('0xf')](function(_0x48f003){logger['info'](_0x360a('0x28'),_0x488560);logger[_0x360a('0x12')](_0x360a('0x28'),_0x488560,JSON['stringify'](_0x48f003));_0x136e33(_0x48f003);})[_0x360a('0x19')](function(_0x1f0d13){logger[_0x360a('0x15')](_0x360a('0x28'),_0x1f0d13[_0x360a('0x17')],_0x488560);_0x5a6f0e(_0x283cf6[_0x360a('0x15')](0x1f4,_0x1f0d13[_0x360a('0x17')]));});});};