c8e316ba2adc04b49a83d202d871fe62451e2f1c
[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 _0xc3cf=['result','catch','GetVoiceQueueReport','VoiceQueueReport','findAll','options','where','limit','include','map','model','attributes','CreateVoiceQueueReport','create','body','raw','then','UpdateVoiceQueueReport','lodash','moment','ioredis','../../mysqldb','../../config/utils','rpc','client','http','redis','defaults','localhost','socket.io-emitter','./voiceQueueReport.socket','register','request','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x43f748,_0x2afb5f){var _0x2b6349=function(_0x26c642){while(--_0x26c642){_0x43f748['push'](_0x43f748['shift']());}};_0x2b6349(++_0x2afb5f);}(_0xc3cf,0x162));var _0xfc3c=function(_0x29bf84,_0x35cd97){_0x29bf84=_0x29bf84-0x0;var _0x16ed99=_0xc3cf[_0x29bf84];return _0x16ed99;};'use strict';var _=require(_0xfc3c('0x0'));var util=require('util');var moment=require(_0xfc3c('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xfc3c('0x2'));var db=require(_0xfc3c('0x3'))['db'];var utils=require(_0xfc3c('0x4'));var logger=require('../../config/logger')(_0xfc3c('0x5'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xfc3c('0x6')][_0xfc3c('0x7')]({'port':0x232a});config[_0xfc3c('0x8')]=_[_0xfc3c('0x9')](config[_0xfc3c('0x8')],{'host':_0xfc3c('0xa'),'port':0x18eb});var socket=require(_0xfc3c('0xb'))(new Redis(config[_0xfc3c('0x8')]));require(_0xfc3c('0xc'))[_0xfc3c('0xd')](socket);function respondWithRpcPromise(_0x412351,_0x327ca3,_0x121ba1){return new BPromise(function(_0x349731,_0xc8b309){return client[_0xfc3c('0xe')](_0x412351,_0x121ba1)['then'](function(_0x1c4004){logger[_0xfc3c('0xf')](_0xfc3c('0x10'),_0x327ca3,_0xfc3c('0x11'));logger[_0xfc3c('0x12')](_0xfc3c('0x13'),_0x327ca3,_0xfc3c('0x11'),JSON[_0xfc3c('0x14')](_0x1c4004));if(_0x1c4004[_0xfc3c('0x15')]){if(_0x1c4004['error'][_0xfc3c('0x16')]===0x1f4){logger['error'](_0xfc3c('0x10'),_0x327ca3,_0x1c4004['error']['message']);return _0xc8b309(_0x1c4004[_0xfc3c('0x15')][_0xfc3c('0x17')]);}logger[_0xfc3c('0x15')](_0xfc3c('0x10'),_0x327ca3,_0x1c4004[_0xfc3c('0x15')]['message']);return _0x349731(_0x1c4004['error'][_0xfc3c('0x17')]);}else{logger[_0xfc3c('0xf')](_0xfc3c('0x10'),_0x327ca3,'request\x20sent');_0x349731(_0x1c4004[_0xfc3c('0x18')][_0xfc3c('0x17')]);}})[_0xfc3c('0x19')](function(_0xab5c17){logger[_0xfc3c('0x15')]('VoiceQueueReport,\x20%s,\x20%s',_0x327ca3,_0xab5c17);_0xc8b309(_0xab5c17);});});}exports[_0xfc3c('0x1a')]=function(_0x4ca602){var _0x4bda41=this;return new Promise(function(_0x3d9a67,_0x447a6d){return db[_0xfc3c('0x1b')][_0xfc3c('0x1c')]({'raw':_0x4ca602[_0xfc3c('0x1d')]?_0x4ca602['options']['raw']===undefined?!![]:![]:!![],'where':_0x4ca602[_0xfc3c('0x1d')]?_0x4ca602['options'][_0xfc3c('0x1e')]||null:null,'attributes':_0x4ca602[_0xfc3c('0x1d')]?_0x4ca602[_0xfc3c('0x1d')]['attributes']||null:null,'limit':_0x4ca602['options']?_0x4ca602[_0xfc3c('0x1d')][_0xfc3c('0x1f')]||null:null,'include':_0x4ca602[_0xfc3c('0x1d')]?_0x4ca602[_0xfc3c('0x1d')][_0xfc3c('0x20')]?_[_0xfc3c('0x21')](_0x4ca602[_0xfc3c('0x1d')]['include'],function(_0x252358){return{'model':db[_0x252358[_0xfc3c('0x22')]],'as':_0x252358['as'],'attributes':_0x252358[_0xfc3c('0x23')],'include':_0x252358[_0xfc3c('0x20')]?_[_0xfc3c('0x21')](_0x252358[_0xfc3c('0x20')],function(_0x23ccf3){return{'model':db[_0x23ccf3[_0xfc3c('0x22')]],'as':_0x23ccf3['as'],'attributes':_0x23ccf3[_0xfc3c('0x23')],'include':_0x23ccf3[_0xfc3c('0x20')]?_['map'](_0x23ccf3[_0xfc3c('0x20')],function(_0x477081){return{'model':db[_0x477081[_0xfc3c('0x22')]],'as':_0x477081['as'],'attributes':_0x477081['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x8732e6){logger['info'](_0xfc3c('0x1a'),_0x4ca602);logger[_0xfc3c('0x12')](_0xfc3c('0x1a'),_0x4ca602,JSON[_0xfc3c('0x14')](_0x8732e6));_0x3d9a67(_0x8732e6);})[_0xfc3c('0x19')](function(_0x2d6871){logger[_0xfc3c('0x15')]('GetVoiceQueueReport',_0x2d6871[_0xfc3c('0x17')],_0x4ca602);_0x447a6d(_0x4bda41['error'](0x1f4,_0x2d6871['message']));});});};exports[_0xfc3c('0x24')]=function(_0xe23f32){var _0xb2724f=this;return new Promise(function(_0x21ccbe,_0x30ce78){return db['VoiceQueueReport'][_0xfc3c('0x25')](_0xe23f32[_0xfc3c('0x26')],{'raw':_0xe23f32[_0xfc3c('0x1d')]?_0xe23f32['options'][_0xfc3c('0x27')]===undefined?!![]:![]:!![]})[_0xfc3c('0x28')](function(_0x5c2c26){logger[_0xfc3c('0xf')](_0xfc3c('0x24'),_0xe23f32);logger[_0xfc3c('0x12')](_0xfc3c('0x24'),_0xe23f32,JSON[_0xfc3c('0x14')](_0x5c2c26));_0x21ccbe(_0x5c2c26);})['catch'](function(_0x3d31e1){logger[_0xfc3c('0x15')](_0xfc3c('0x24'),_0x3d31e1['message'],_0xe23f32);_0x30ce78(_0xb2724f[_0xfc3c('0x15')](0x1f4,_0x3d31e1[_0xfc3c('0x17')]));});});};exports['UpdateVoiceQueueReport']=function(_0x2f9bef){var _0x2c4602=this;return new Promise(function(_0x2a4601,_0x592768){return db['VoiceQueueReport']['update'](_0x2f9bef[_0xfc3c('0x26')],{'raw':_0x2f9bef['options']?_0x2f9bef[_0xfc3c('0x1d')][_0xfc3c('0x27')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2f9bef['options']?_0x2f9bef[_0xfc3c('0x1d')][_0xfc3c('0x1e')]||null:null,'attributes':_0x2f9bef['options']?_0x2f9bef[_0xfc3c('0x1d')]['attributes']||null:null,'limit':_0x2f9bef[_0xfc3c('0x1d')]?_0x2f9bef[_0xfc3c('0x1d')][_0xfc3c('0x1f')]||null:null})[_0xfc3c('0x28')](function(_0x1c9dff){logger[_0xfc3c('0xf')](_0xfc3c('0x29'),_0x2f9bef);logger[_0xfc3c('0x12')](_0xfc3c('0x29'),_0x2f9bef,JSON[_0xfc3c('0x14')](_0x1c9dff));_0x2a4601(_0x1c9dff);})[_0xfc3c('0x19')](function(_0x35a91d){logger['error']('UpdateVoiceQueueReport',_0x35a91d[_0xfc3c('0x17')],_0x2f9bef);_0x592768(_0x2c4602['error'](0x1f4,_0x35a91d[_0xfc3c('0x17')]));});});};