3b025b8ced144c42a994e42f05212832c5c150af
[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 _0x0562=['attributes','map','include','model','GetVoiceQueueReport','CreateVoiceQueueReport','VoiceQueueReport','create','UpdateVoiceQueueReport','limit','then','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/environment','client','http','redis','defaults','socket.io-emitter','./voiceQueueReport.socket','register','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','findAll','options','raw','where'];(function(_0x27bc7a,_0xad4683){var _0xc90f74=function(_0x203bb2){while(--_0x203bb2){_0x27bc7a['push'](_0x27bc7a['shift']());}};_0xc90f74(++_0xad4683);}(_0x0562,0x16a));var _0x2056=function(_0x58122d,_0x3db6a0){_0x58122d=_0x58122d-0x0;var _0x2551ec=_0x0562[_0x58122d];return _0x2551ec;};'use strict';var _=require('lodash');var util=require(_0x2056('0x0'));var moment=require('moment');var BPromise=require(_0x2056('0x1'));var rs=require(_0x2056('0x2'));var fs=require('fs');var Redis=require(_0x2056('0x3'));var db=require(_0x2056('0x4'))['db'];var utils=require(_0x2056('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x2056('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x2056('0x7')][_0x2056('0x8')]({'port':0x232a});config[_0x2056('0x9')]=_[_0x2056('0xa')](config[_0x2056('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x2056('0xb'))(new Redis(config['redis']));require(_0x2056('0xc'))[_0x2056('0xd')](socket);function respondWithRpcPromise(_0x13b853,_0x24a40d,_0x1aef24){return new BPromise(function(_0x3da2f6,_0x45068f){return client['request'](_0x13b853,_0x1aef24)['then'](function(_0x1ffc0b){logger['info'](_0x2056('0xe'),_0x24a40d,_0x2056('0xf'));logger[_0x2056('0x10')]('VoiceQueueReport,\x20%s,\x20%s,\x20%s',_0x24a40d,_0x2056('0xf'),JSON[_0x2056('0x11')](_0x1ffc0b));if(_0x1ffc0b[_0x2056('0x12')]){if(_0x1ffc0b['error'][_0x2056('0x13')]===0x1f4){logger[_0x2056('0x12')](_0x2056('0xe'),_0x24a40d,_0x1ffc0b[_0x2056('0x12')][_0x2056('0x14')]);return _0x45068f(_0x1ffc0b['error']['message']);}logger[_0x2056('0x12')](_0x2056('0xe'),_0x24a40d,_0x1ffc0b['error']['message']);return _0x3da2f6(_0x1ffc0b['error'][_0x2056('0x14')]);}else{logger[_0x2056('0x15')](_0x2056('0xe'),_0x24a40d,_0x2056('0xf'));_0x3da2f6(_0x1ffc0b[_0x2056('0x16')][_0x2056('0x14')]);}})[_0x2056('0x17')](function(_0x51b930){logger[_0x2056('0x12')](_0x2056('0xe'),_0x24a40d,_0x51b930);_0x45068f(_0x51b930);});});}exports['GetVoiceQueueReport']=function(_0x217bd5){var _0x1202fa=this;return new Promise(function(_0x15d3db,_0x2dd832){return db['VoiceQueueReport'][_0x2056('0x18')]({'raw':_0x217bd5[_0x2056('0x19')]?_0x217bd5[_0x2056('0x19')][_0x2056('0x1a')]===undefined?!![]:![]:!![],'where':_0x217bd5['options']?_0x217bd5['options'][_0x2056('0x1b')]||null:null,'attributes':_0x217bd5[_0x2056('0x19')]?_0x217bd5[_0x2056('0x19')]['attributes']||null:null,'limit':_0x217bd5['options']?_0x217bd5['options']['limit']||null:null,'include':_0x217bd5[_0x2056('0x19')]?_0x217bd5[_0x2056('0x19')]['include']?_['map'](_0x217bd5[_0x2056('0x19')]['include'],function(_0xa8f397){return{'model':db[_0xa8f397['model']],'as':_0xa8f397['as'],'attributes':_0xa8f397[_0x2056('0x1c')],'include':_0xa8f397['include']?_[_0x2056('0x1d')](_0xa8f397[_0x2056('0x1e')],function(_0x183f32){return{'model':db[_0x183f32[_0x2056('0x1f')]],'as':_0x183f32['as'],'attributes':_0x183f32[_0x2056('0x1c')],'include':_0x183f32[_0x2056('0x1e')]?_[_0x2056('0x1d')](_0x183f32[_0x2056('0x1e')],function(_0x45813f){return{'model':db[_0x45813f[_0x2056('0x1f')]],'as':_0x45813f['as'],'attributes':_0x45813f[_0x2056('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1e7c5c){logger['info'](_0x2056('0x20'),_0x217bd5);logger[_0x2056('0x10')](_0x2056('0x20'),_0x217bd5,JSON[_0x2056('0x11')](_0x1e7c5c));_0x15d3db(_0x1e7c5c);})['catch'](function(_0x3dacd9){logger[_0x2056('0x12')](_0x2056('0x20'),_0x3dacd9[_0x2056('0x14')],_0x217bd5);_0x2dd832(_0x1202fa[_0x2056('0x12')](0x1f4,_0x3dacd9[_0x2056('0x14')]));});});};exports[_0x2056('0x21')]=function(_0x4de19b){var _0x3c92a4=this;return new Promise(function(_0x5070c8,_0x4f4ec4){return db[_0x2056('0x22')][_0x2056('0x23')](_0x4de19b['body'],{'raw':_0x4de19b[_0x2056('0x19')]?_0x4de19b[_0x2056('0x19')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x233577){logger[_0x2056('0x15')]('CreateVoiceQueueReport',_0x4de19b);logger[_0x2056('0x10')](_0x2056('0x21'),_0x4de19b,JSON[_0x2056('0x11')](_0x233577));_0x5070c8(_0x233577);})[_0x2056('0x17')](function(_0xf21903){logger[_0x2056('0x12')](_0x2056('0x21'),_0xf21903[_0x2056('0x14')],_0x4de19b);_0x4f4ec4(_0x3c92a4[_0x2056('0x12')](0x1f4,_0xf21903[_0x2056('0x14')]));});});};exports[_0x2056('0x24')]=function(_0x201238){var _0x4c347f=this;return new Promise(function(_0xbf5789,_0x55e5d0){return db['VoiceQueueReport']['update'](_0x201238['body'],{'raw':_0x201238[_0x2056('0x19')]?_0x201238[_0x2056('0x19')][_0x2056('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x201238[_0x2056('0x19')]?_0x201238['options'][_0x2056('0x1b')]||null:null,'attributes':_0x201238['options']?_0x201238[_0x2056('0x19')][_0x2056('0x1c')]||null:null,'limit':_0x201238[_0x2056('0x19')]?_0x201238[_0x2056('0x19')][_0x2056('0x25')]||null:null})[_0x2056('0x26')](function(_0x3d4934){logger[_0x2056('0x15')](_0x2056('0x24'),_0x201238);logger[_0x2056('0x10')](_0x2056('0x24'),_0x201238,JSON[_0x2056('0x11')](_0x3d4934));_0xbf5789(_0x3d4934);})[_0x2056('0x17')](function(_0x263830){logger[_0x2056('0x12')](_0x2056('0x24'),_0x263830['message'],_0x201238);_0x55e5d0(_0x4c347f['error'](0x1f4,_0x263830[_0x2056('0x14')]));});});};