Built motion from commit 013e4bb4.|2.6.18
[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 _0xdbb3=['rpc','../../config/environment','client','http','defaults','redis','localhost','socket.io-emitter','./voiceQueueReport.socket','register','then','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetVoiceQueueReport','VoiceQueueReport','options','where','limit','map','include','model','attributes','CreateVoiceQueueReport','create','body','UpdateVoiceQueueReport','update','raw','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x118881,_0x437889){var _0x32a5bd=function(_0x2e7a74){while(--_0x2e7a74){_0x118881['push'](_0x118881['shift']());}};_0x32a5bd(++_0x437889);}(_0xdbb3,0x1a7));var _0x3dbb=function(_0x4bfac3,_0x58324d){_0x4bfac3=_0x4bfac3-0x0;var _0x15f0f2=_0xdbb3[_0x4bfac3];return _0x15f0f2;};'use strict';var _=require('lodash');var util=require(_0x3dbb('0x0'));var moment=require(_0x3dbb('0x1'));var BPromise=require(_0x3dbb('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3dbb('0x3'));var db=require(_0x3dbb('0x4'))['db'];var utils=require(_0x3dbb('0x5'));var logger=require(_0x3dbb('0x6'))(_0x3dbb('0x7'));var config=require(_0x3dbb('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x3dbb('0x9')][_0x3dbb('0xa')]({'port':0x232a});config['redis']=_[_0x3dbb('0xb')](config[_0x3dbb('0xc')],{'host':_0x3dbb('0xd'),'port':0x18eb});var socket=require(_0x3dbb('0xe'))(new Redis(config[_0x3dbb('0xc')]));require(_0x3dbb('0xf'))[_0x3dbb('0x10')](socket);function respondWithRpcPromise(_0x4b1075,_0x42e9e7,_0x251c0d){return new BPromise(function(_0xcd7491,_0x5d9a30){return client['request'](_0x4b1075,_0x251c0d)[_0x3dbb('0x11')](function(_0x12c9f5){logger[_0x3dbb('0x12')](_0x3dbb('0x13'),_0x42e9e7,_0x3dbb('0x14'));logger[_0x3dbb('0x15')](_0x3dbb('0x16'),_0x42e9e7,_0x3dbb('0x14'),JSON[_0x3dbb('0x17')](_0x12c9f5));if(_0x12c9f5['error']){if(_0x12c9f5['error']['code']===0x1f4){logger[_0x3dbb('0x18')](_0x3dbb('0x13'),_0x42e9e7,_0x12c9f5[_0x3dbb('0x18')][_0x3dbb('0x19')]);return _0x5d9a30(_0x12c9f5[_0x3dbb('0x18')][_0x3dbb('0x19')]);}logger[_0x3dbb('0x18')](_0x3dbb('0x13'),_0x42e9e7,_0x12c9f5[_0x3dbb('0x18')][_0x3dbb('0x19')]);return _0xcd7491(_0x12c9f5[_0x3dbb('0x18')][_0x3dbb('0x19')]);}else{logger[_0x3dbb('0x12')](_0x3dbb('0x13'),_0x42e9e7,'request\x20sent');_0xcd7491(_0x12c9f5[_0x3dbb('0x1a')][_0x3dbb('0x19')]);}})[_0x3dbb('0x1b')](function(_0x51b6ec){logger['error'](_0x3dbb('0x13'),_0x42e9e7,_0x51b6ec);_0x5d9a30(_0x51b6ec);});});}exports[_0x3dbb('0x1c')]=function(_0xdb46df){var _0x40da8f=this;return new Promise(function(_0x48f375,_0x52af90){return db[_0x3dbb('0x1d')]['findAll']({'raw':_0xdb46df['options']?_0xdb46df[_0x3dbb('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0xdb46df['options']?_0xdb46df[_0x3dbb('0x1e')][_0x3dbb('0x1f')]||null:null,'attributes':_0xdb46df[_0x3dbb('0x1e')]?_0xdb46df['options']['attributes']||null:null,'limit':_0xdb46df[_0x3dbb('0x1e')]?_0xdb46df[_0x3dbb('0x1e')][_0x3dbb('0x20')]||null:null,'include':_0xdb46df[_0x3dbb('0x1e')]?_0xdb46df['options']['include']?_[_0x3dbb('0x21')](_0xdb46df[_0x3dbb('0x1e')][_0x3dbb('0x22')],function(_0x326ff5){return{'model':db[_0x326ff5[_0x3dbb('0x23')]],'as':_0x326ff5['as'],'attributes':_0x326ff5['attributes'],'include':_0x326ff5[_0x3dbb('0x22')]?_[_0x3dbb('0x21')](_0x326ff5[_0x3dbb('0x22')],function(_0x493cbb){return{'model':db[_0x493cbb['model']],'as':_0x493cbb['as'],'attributes':_0x493cbb[_0x3dbb('0x24')],'include':_0x493cbb[_0x3dbb('0x22')]?_[_0x3dbb('0x21')](_0x493cbb[_0x3dbb('0x22')],function(_0x134a68){return{'model':db[_0x134a68[_0x3dbb('0x23')]],'as':_0x134a68['as'],'attributes':_0x134a68[_0x3dbb('0x24')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3d1570){logger[_0x3dbb('0x12')](_0x3dbb('0x1c'),_0xdb46df);logger[_0x3dbb('0x15')](_0x3dbb('0x1c'),_0xdb46df,JSON['stringify'](_0x3d1570));_0x48f375(_0x3d1570);})['catch'](function(_0x4de985){logger[_0x3dbb('0x18')]('GetVoiceQueueReport',_0x4de985[_0x3dbb('0x19')],_0xdb46df);_0x52af90(_0x40da8f[_0x3dbb('0x18')](0x1f4,_0x4de985[_0x3dbb('0x19')]));});});};exports[_0x3dbb('0x25')]=function(_0x5de60e){var _0x2e7732=this;return new Promise(function(_0x3bcaf2,_0x1f1bb3){return db[_0x3dbb('0x1d')][_0x3dbb('0x26')](_0x5de60e[_0x3dbb('0x27')],{'raw':_0x5de60e['options']?_0x5de60e[_0x3dbb('0x1e')]['raw']===undefined?!![]:![]:!![]})[_0x3dbb('0x11')](function(_0x56b7e4){logger['info'](_0x3dbb('0x25'),_0x5de60e);logger[_0x3dbb('0x15')]('CreateVoiceQueueReport',_0x5de60e,JSON[_0x3dbb('0x17')](_0x56b7e4));_0x3bcaf2(_0x56b7e4);})['catch'](function(_0x5c1158){logger[_0x3dbb('0x18')](_0x3dbb('0x25'),_0x5c1158[_0x3dbb('0x19')],_0x5de60e);_0x1f1bb3(_0x2e7732[_0x3dbb('0x18')](0x1f4,_0x5c1158[_0x3dbb('0x19')]));});});};exports[_0x3dbb('0x28')]=function(_0xb6de0c){var _0x101828=this;return new Promise(function(_0x4a19e7,_0x56f2df){return db[_0x3dbb('0x1d')][_0x3dbb('0x29')](_0xb6de0c[_0x3dbb('0x27')],{'raw':_0xb6de0c['options']?_0xb6de0c[_0x3dbb('0x1e')][_0x3dbb('0x2a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xb6de0c[_0x3dbb('0x1e')]?_0xb6de0c[_0x3dbb('0x1e')][_0x3dbb('0x1f')]||null:null,'attributes':_0xb6de0c[_0x3dbb('0x1e')]?_0xb6de0c[_0x3dbb('0x1e')][_0x3dbb('0x24')]||null:null,'limit':_0xb6de0c[_0x3dbb('0x1e')]?_0xb6de0c[_0x3dbb('0x1e')]['limit']||null:null})[_0x3dbb('0x11')](function(_0x275a5f){logger[_0x3dbb('0x12')]('UpdateVoiceQueueReport',_0xb6de0c);logger[_0x3dbb('0x15')](_0x3dbb('0x28'),_0xb6de0c,JSON[_0x3dbb('0x17')](_0x275a5f));_0x4a19e7(_0x275a5f);})[_0x3dbb('0x1b')](function(_0x58885c){logger[_0x3dbb('0x18')](_0x3dbb('0x28'),_0x58885c[_0x3dbb('0x19')],_0xb6de0c);_0x56f2df(_0x101828[_0x3dbb('0x18')](0x1f4,_0x58885c[_0x3dbb('0x19')]));});});};