569304780938ff747c8bfd37ec635f97c3dbdfa6
[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 _0x89a7=['UpdateVoiceQueueReport','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','socket.io-emitter','./voiceQueueReport.socket','request','then','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetVoiceQueueReport','VoiceQueueReport','findAll','options','raw','where','attributes','limit','include','model','map','catch','CreateVoiceQueueReport','create'];(function(_0x238933,_0x480ab4){var _0x544360=function(_0x5c2ebf){while(--_0x5c2ebf){_0x238933['push'](_0x238933['shift']());}};_0x544360(++_0x480ab4);}(_0x89a7,0x1cf));var _0x789a=function(_0x4d92d1,_0x4ea61c){_0x4d92d1=_0x4d92d1-0x0;var _0x3d9830=_0x89a7[_0x4d92d1];return _0x3d9830;};'use strict';var _=require(_0x789a('0x0'));var util=require('util');var moment=require(_0x789a('0x1'));var BPromise=require('bluebird');var rs=require(_0x789a('0x2'));var fs=require('fs');var Redis=require(_0x789a('0x3'));var db=require(_0x789a('0x4'))['db'];var utils=require(_0x789a('0x5'));var logger=require(_0x789a('0x6'))(_0x789a('0x7'));var config=require(_0x789a('0x8'));var jayson=require(_0x789a('0x9'));var client=jayson[_0x789a('0xa')]['http']({'port':0x232a});config[_0x789a('0xb')]=_[_0x789a('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x789a('0xd'))(new Redis(config[_0x789a('0xb')]));require(_0x789a('0xe'))['register'](socket);function respondWithRpcPromise(_0x44fb68,_0x5bc503,_0x48f755){return new BPromise(function(_0x1f292b,_0x13b7f2){return client[_0x789a('0xf')](_0x44fb68,_0x48f755)[_0x789a('0x10')](function(_0x310962){logger[_0x789a('0x11')](_0x789a('0x12'),_0x5bc503,_0x789a('0x13'));logger[_0x789a('0x14')](_0x789a('0x15'),_0x5bc503,'request\x20sent',JSON[_0x789a('0x16')](_0x310962));if(_0x310962[_0x789a('0x17')]){if(_0x310962[_0x789a('0x17')][_0x789a('0x18')]===0x1f4){logger['error'](_0x789a('0x12'),_0x5bc503,_0x310962[_0x789a('0x17')]['message']);return _0x13b7f2(_0x310962['error'][_0x789a('0x19')]);}logger[_0x789a('0x17')]('VoiceQueueReport,\x20%s,\x20%s',_0x5bc503,_0x310962[_0x789a('0x17')][_0x789a('0x19')]);return _0x1f292b(_0x310962[_0x789a('0x17')][_0x789a('0x19')]);}else{logger[_0x789a('0x11')]('VoiceQueueReport,\x20%s,\x20%s',_0x5bc503,_0x789a('0x13'));_0x1f292b(_0x310962[_0x789a('0x1a')][_0x789a('0x19')]);}})['catch'](function(_0x4745bf){logger[_0x789a('0x17')]('VoiceQueueReport,\x20%s,\x20%s',_0x5bc503,_0x4745bf);_0x13b7f2(_0x4745bf);});});}exports[_0x789a('0x1b')]=function(_0x2b9482){var _0x686f33=this;return new Promise(function(_0x552a71,_0x37121c){return db[_0x789a('0x1c')][_0x789a('0x1d')]({'raw':_0x2b9482['options']?_0x2b9482[_0x789a('0x1e')][_0x789a('0x1f')]===undefined?!![]:![]:!![],'where':_0x2b9482[_0x789a('0x1e')]?_0x2b9482[_0x789a('0x1e')][_0x789a('0x20')]||null:null,'attributes':_0x2b9482[_0x789a('0x1e')]?_0x2b9482[_0x789a('0x1e')][_0x789a('0x21')]||null:null,'limit':_0x2b9482[_0x789a('0x1e')]?_0x2b9482[_0x789a('0x1e')][_0x789a('0x22')]||null:null,'include':_0x2b9482[_0x789a('0x1e')]?_0x2b9482['options']['include']?_['map'](_0x2b9482[_0x789a('0x1e')][_0x789a('0x23')],function(_0x5f5660){return{'model':db[_0x5f5660[_0x789a('0x24')]],'as':_0x5f5660['as'],'attributes':_0x5f5660[_0x789a('0x21')],'include':_0x5f5660[_0x789a('0x23')]?_[_0x789a('0x25')](_0x5f5660[_0x789a('0x23')],function(_0x329053){return{'model':db[_0x329053['model']],'as':_0x329053['as'],'attributes':_0x329053['attributes'],'include':_0x329053[_0x789a('0x23')]?_[_0x789a('0x25')](_0x329053[_0x789a('0x23')],function(_0x3360d3){return{'model':db[_0x3360d3[_0x789a('0x24')]],'as':_0x3360d3['as'],'attributes':_0x3360d3[_0x789a('0x21')]};}):[]};}):[]};}):[]:[]})[_0x789a('0x10')](function(_0x1084ae){logger[_0x789a('0x11')]('GetVoiceQueueReport',_0x2b9482);logger['debug']('GetVoiceQueueReport',_0x2b9482,JSON['stringify'](_0x1084ae));_0x552a71(_0x1084ae);})[_0x789a('0x26')](function(_0x1850e2){logger[_0x789a('0x17')](_0x789a('0x1b'),_0x1850e2['message'],_0x2b9482);_0x37121c(_0x686f33[_0x789a('0x17')](0x1f4,_0x1850e2['message']));});});};exports[_0x789a('0x27')]=function(_0x2925e5){var _0x52a2a7=this;return new Promise(function(_0x3e5375,_0x16b020){return db[_0x789a('0x1c')][_0x789a('0x28')](_0x2925e5['body'],{'raw':_0x2925e5[_0x789a('0x1e')]?_0x2925e5['options']['raw']===undefined?!![]:![]:!![]})[_0x789a('0x10')](function(_0x36f4a4){logger['info']('CreateVoiceQueueReport',_0x2925e5);logger[_0x789a('0x14')](_0x789a('0x27'),_0x2925e5,JSON[_0x789a('0x16')](_0x36f4a4));_0x3e5375(_0x36f4a4);})[_0x789a('0x26')](function(_0x1ed595){logger[_0x789a('0x17')]('CreateVoiceQueueReport',_0x1ed595[_0x789a('0x19')],_0x2925e5);_0x16b020(_0x52a2a7[_0x789a('0x17')](0x1f4,_0x1ed595[_0x789a('0x19')]));});});};exports[_0x789a('0x29')]=function(_0x3df7a0){var _0x29d506=this;return new Promise(function(_0x801517,_0x289e42){return db['VoiceQueueReport']['update'](_0x3df7a0['body'],{'raw':_0x3df7a0[_0x789a('0x1e')]?_0x3df7a0[_0x789a('0x1e')][_0x789a('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3df7a0['options']?_0x3df7a0['options']['where']||null:null,'attributes':_0x3df7a0[_0x789a('0x1e')]?_0x3df7a0['options']['attributes']||null:null,'limit':_0x3df7a0[_0x789a('0x1e')]?_0x3df7a0[_0x789a('0x1e')][_0x789a('0x22')]||null:null})['then'](function(_0x43b9db){logger[_0x789a('0x11')](_0x789a('0x29'),_0x3df7a0);logger[_0x789a('0x14')](_0x789a('0x29'),_0x3df7a0,JSON['stringify'](_0x43b9db));_0x801517(_0x43b9db);})['catch'](function(_0x338337){logger[_0x789a('0x17')](_0x789a('0x29'),_0x338337[_0x789a('0x19')],_0x3df7a0);_0x289e42(_0x29d506[_0x789a('0x17')](0x1f4,_0x338337[_0x789a('0x19')]));});});};