f740fd0d2296957b727d0dbc3ebcf28620e32f49
[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 _0xaa14=['../../config/environment','jayson/promise','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','code','message','result','catch','GetVoiceQueueReport','VoiceQueueReport','options','where','attributes','limit','map','include','CreateVoiceQueueReport','create','raw','UpdateVoiceQueueReport','body','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc'];(function(_0x4995f7,_0x37f1c8){var _0x100c7e=function(_0x369b95){while(--_0x369b95){_0x4995f7['push'](_0x4995f7['shift']());}};_0x100c7e(++_0x37f1c8);}(_0xaa14,0xe7));var _0x4aa1=function(_0x53348c,_0x21ede1){_0x53348c=_0x53348c-0x0;var _0x35b11c=_0xaa14[_0x53348c];return _0x35b11c;};'use strict';var _=require(_0x4aa1('0x0'));var util=require(_0x4aa1('0x1'));var moment=require(_0x4aa1('0x2'));var BPromise=require(_0x4aa1('0x3'));var rs=require(_0x4aa1('0x4'));var fs=require('fs');var Redis=require(_0x4aa1('0x5'));var db=require(_0x4aa1('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x4aa1('0x7'))(_0x4aa1('0x8'));var config=require(_0x4aa1('0x9'));var jayson=require(_0x4aa1('0xa'));var client=jayson['client']['http']({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0x4aa1('0xb'),'port':0x18eb});var socket=require(_0x4aa1('0xc'))(new Redis(config['redis']));require(_0x4aa1('0xd'))[_0x4aa1('0xe')](socket);function respondWithRpcPromise(_0x38c1e3,_0x39026b,_0x3c75d4){return new BPromise(function(_0x1f3395,_0x5e7dfb){return client['request'](_0x38c1e3,_0x3c75d4)[_0x4aa1('0xf')](function(_0x4e0e40){logger[_0x4aa1('0x10')](_0x4aa1('0x11'),_0x39026b,_0x4aa1('0x12'));logger[_0x4aa1('0x13')](_0x4aa1('0x14'),_0x39026b,'request\x20sent',JSON[_0x4aa1('0x15')](_0x4e0e40));if(_0x4e0e40['error']){if(_0x4e0e40[_0x4aa1('0x16')][_0x4aa1('0x17')]===0x1f4){logger[_0x4aa1('0x16')](_0x4aa1('0x11'),_0x39026b,_0x4e0e40[_0x4aa1('0x16')][_0x4aa1('0x18')]);return _0x5e7dfb(_0x4e0e40[_0x4aa1('0x16')][_0x4aa1('0x18')]);}logger[_0x4aa1('0x16')](_0x4aa1('0x11'),_0x39026b,_0x4e0e40[_0x4aa1('0x16')][_0x4aa1('0x18')]);return _0x1f3395(_0x4e0e40[_0x4aa1('0x16')][_0x4aa1('0x18')]);}else{logger[_0x4aa1('0x10')](_0x4aa1('0x11'),_0x39026b,_0x4aa1('0x12'));_0x1f3395(_0x4e0e40[_0x4aa1('0x19')][_0x4aa1('0x18')]);}})[_0x4aa1('0x1a')](function(_0x58105d){logger[_0x4aa1('0x16')](_0x4aa1('0x11'),_0x39026b,_0x58105d);_0x5e7dfb(_0x58105d);});});}exports[_0x4aa1('0x1b')]=function(_0x377b21){var _0x57e70d=this;return new Promise(function(_0x5c493f,_0x43271c){return db[_0x4aa1('0x1c')]['findAll']({'raw':_0x377b21[_0x4aa1('0x1d')]?_0x377b21[_0x4aa1('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x377b21[_0x4aa1('0x1d')]?_0x377b21['options'][_0x4aa1('0x1e')]||null:null,'attributes':_0x377b21[_0x4aa1('0x1d')]?_0x377b21[_0x4aa1('0x1d')][_0x4aa1('0x1f')]||null:null,'limit':_0x377b21[_0x4aa1('0x1d')]?_0x377b21[_0x4aa1('0x1d')][_0x4aa1('0x20')]||null:null,'include':_0x377b21[_0x4aa1('0x1d')]?_0x377b21['options']['include']?_[_0x4aa1('0x21')](_0x377b21[_0x4aa1('0x1d')]['include'],function(_0x586c85){return{'model':db[_0x586c85['model']],'as':_0x586c85['as'],'attributes':_0x586c85['attributes'],'include':_0x586c85[_0x4aa1('0x22')]?_[_0x4aa1('0x21')](_0x586c85[_0x4aa1('0x22')],function(_0x85d7eb){return{'model':db[_0x85d7eb['model']],'as':_0x85d7eb['as'],'attributes':_0x85d7eb[_0x4aa1('0x1f')],'include':_0x85d7eb[_0x4aa1('0x22')]?_['map'](_0x85d7eb[_0x4aa1('0x22')],function(_0x432486){return{'model':db[_0x432486['model']],'as':_0x432486['as'],'attributes':_0x432486[_0x4aa1('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x4aa1('0xf')](function(_0x5a53c2){logger[_0x4aa1('0x10')](_0x4aa1('0x1b'),_0x377b21);logger[_0x4aa1('0x13')](_0x4aa1('0x1b'),_0x377b21,JSON['stringify'](_0x5a53c2));_0x5c493f(_0x5a53c2);})[_0x4aa1('0x1a')](function(_0x54bc14){logger[_0x4aa1('0x16')](_0x4aa1('0x1b'),_0x54bc14[_0x4aa1('0x18')],_0x377b21);_0x43271c(_0x57e70d['error'](0x1f4,_0x54bc14[_0x4aa1('0x18')]));});});};exports[_0x4aa1('0x23')]=function(_0x552b35){var _0x1ff61b=this;return new Promise(function(_0x2e7b7f,_0x3336f1){return db['VoiceQueueReport'][_0x4aa1('0x24')](_0x552b35['body'],{'raw':_0x552b35[_0x4aa1('0x1d')]?_0x552b35[_0x4aa1('0x1d')][_0x4aa1('0x25')]===undefined?!![]:![]:!![]})[_0x4aa1('0xf')](function(_0x3645d7){logger['info'](_0x4aa1('0x23'),_0x552b35);logger[_0x4aa1('0x13')](_0x4aa1('0x23'),_0x552b35,JSON[_0x4aa1('0x15')](_0x3645d7));_0x2e7b7f(_0x3645d7);})[_0x4aa1('0x1a')](function(_0x275e06){logger[_0x4aa1('0x16')]('CreateVoiceQueueReport',_0x275e06[_0x4aa1('0x18')],_0x552b35);_0x3336f1(_0x1ff61b['error'](0x1f4,_0x275e06[_0x4aa1('0x18')]));});});};exports[_0x4aa1('0x26')]=function(_0x5c1473){var _0x3f5891=this;return new Promise(function(_0x927d1c,_0x2b57c3){return db[_0x4aa1('0x1c')]['update'](_0x5c1473[_0x4aa1('0x27')],{'raw':_0x5c1473[_0x4aa1('0x1d')]?_0x5c1473[_0x4aa1('0x1d')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5c1473[_0x4aa1('0x1d')]?_0x5c1473[_0x4aa1('0x1d')][_0x4aa1('0x1e')]||null:null,'attributes':_0x5c1473['options']?_0x5c1473['options'][_0x4aa1('0x1f')]||null:null,'limit':_0x5c1473[_0x4aa1('0x1d')]?_0x5c1473[_0x4aa1('0x1d')][_0x4aa1('0x20')]||null:null})['then'](function(_0x468c7a){logger[_0x4aa1('0x10')]('UpdateVoiceQueueReport',_0x5c1473);logger['debug']('UpdateVoiceQueueReport',_0x5c1473,JSON[_0x4aa1('0x15')](_0x468c7a));_0x927d1c(_0x468c7a);})[_0x4aa1('0x1a')](function(_0x2f42f9){logger[_0x4aa1('0x16')](_0x4aa1('0x26'),_0x2f42f9[_0x4aa1('0x18')],_0x5c1473);_0x2b57c3(_0x3f5891[_0x4aa1('0x16')](0x1f4,_0x2f42f9[_0x4aa1('0x18')]));});});};