Built motion from commit (unavailable).|2.5.29
[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 _0x7af2=['code','message','result','catch','findAll','options','raw','where','attributes','limit','include','model','map','GetVoiceQueueReport','CreateVoiceQueueReport','VoiceQueueReport','UpdateVoiceQueueReport','body','then','util','moment','randomstring','../../config/logger','rpc','../../config/environment','jayson/promise','http','defaults','localhost','redis','register','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0x3c4737,_0x2329ec){var _0x2bb926=function(_0x3b9605){while(--_0x3b9605){_0x3c4737['push'](_0x3c4737['shift']());}};_0x2bb926(++_0x2329ec);}(_0x7af2,0x169));var _0x27af=function(_0x22c0e1,_0x184a76){_0x22c0e1=_0x22c0e1-0x0;var _0x6a3792=_0x7af2[_0x22c0e1];return _0x6a3792;};'use strict';var _=require('lodash');var util=require(_0x27af('0x0'));var moment=require(_0x27af('0x1'));var BPromise=require('bluebird');var rs=require(_0x27af('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x27af('0x3'))(_0x27af('0x4'));var config=require(_0x27af('0x5'));var jayson=require(_0x27af('0x6'));var client=jayson['client'][_0x27af('0x7')]({'port':0x232a});config['redis']=_[_0x27af('0x8')](config['redis'],{'host':_0x27af('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x27af('0xa')]));require('./voiceQueueReport.socket')[_0x27af('0xb')](socket);function respondWithRpcPromise(_0x393be6,_0x1b2310,_0x1beefc){return new BPromise(function(_0x400e33,_0x2d3155){return client['request'](_0x393be6,_0x1beefc)['then'](function(_0xd0b08d){logger[_0x27af('0xc')](_0x27af('0xd'),_0x1b2310,_0x27af('0xe'));logger[_0x27af('0xf')](_0x27af('0x10'),_0x1b2310,_0x27af('0xe'),JSON[_0x27af('0x11')](_0xd0b08d));if(_0xd0b08d[_0x27af('0x12')]){if(_0xd0b08d[_0x27af('0x12')][_0x27af('0x13')]===0x1f4){logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0x1b2310,_0xd0b08d[_0x27af('0x12')]['message']);return _0x2d3155(_0xd0b08d['error'][_0x27af('0x14')]);}logger['error'](_0x27af('0xd'),_0x1b2310,_0xd0b08d[_0x27af('0x12')]['message']);return _0x400e33(_0xd0b08d[_0x27af('0x12')][_0x27af('0x14')]);}else{logger['info'](_0x27af('0xd'),_0x1b2310,'request\x20sent');_0x400e33(_0xd0b08d[_0x27af('0x15')]['message']);}})[_0x27af('0x16')](function(_0x52ca4a){logger['error'](_0x27af('0xd'),_0x1b2310,_0x52ca4a);_0x2d3155(_0x52ca4a);});});}exports['GetVoiceQueueReport']=function(_0xfe1a7f){var _0x248ba1=this;return new Promise(function(_0xe8cce8,_0x5cd0e3){return db['VoiceQueueReport'][_0x27af('0x17')]({'raw':_0xfe1a7f[_0x27af('0x18')]?_0xfe1a7f['options'][_0x27af('0x19')]===undefined?!![]:![]:!![],'where':_0xfe1a7f['options']?_0xfe1a7f['options'][_0x27af('0x1a')]||null:null,'attributes':_0xfe1a7f['options']?_0xfe1a7f[_0x27af('0x18')][_0x27af('0x1b')]||null:null,'limit':_0xfe1a7f[_0x27af('0x18')]?_0xfe1a7f['options'][_0x27af('0x1c')]||null:null,'include':_0xfe1a7f['options']?_0xfe1a7f['options'][_0x27af('0x1d')]?_['map'](_0xfe1a7f[_0x27af('0x18')][_0x27af('0x1d')],function(_0x55706e){return{'model':db[_0x55706e[_0x27af('0x1e')]],'as':_0x55706e['as'],'attributes':_0x55706e['attributes'],'include':_0x55706e['include']?_[_0x27af('0x1f')](_0x55706e[_0x27af('0x1d')],function(_0xf37e67){return{'model':db[_0xf37e67[_0x27af('0x1e')]],'as':_0xf37e67['as'],'attributes':_0xf37e67[_0x27af('0x1b')],'include':_0xf37e67[_0x27af('0x1d')]?_['map'](_0xf37e67[_0x27af('0x1d')],function(_0x29d07a){return{'model':db[_0x29d07a[_0x27af('0x1e')]],'as':_0x29d07a['as'],'attributes':_0x29d07a[_0x27af('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4de04f){logger[_0x27af('0xc')](_0x27af('0x20'),_0xfe1a7f);logger[_0x27af('0xf')](_0x27af('0x20'),_0xfe1a7f,JSON[_0x27af('0x11')](_0x4de04f));_0xe8cce8(_0x4de04f);})[_0x27af('0x16')](function(_0x43ab7c){logger[_0x27af('0x12')]('GetVoiceQueueReport',_0x43ab7c['message'],_0xfe1a7f);_0x5cd0e3(_0x248ba1['error'](0x1f4,_0x43ab7c[_0x27af('0x14')]));});});};exports[_0x27af('0x21')]=function(_0xd501da){var _0x5be9f5=this;return new Promise(function(_0x56cf16,_0x10a293){return db[_0x27af('0x22')]['create'](_0xd501da['body'],{'raw':_0xd501da[_0x27af('0x18')]?_0xd501da['options'][_0x27af('0x19')]===undefined?!![]:![]:!![]})['then'](function(_0x4051f5){logger[_0x27af('0xc')]('CreateVoiceQueueReport',_0xd501da);logger[_0x27af('0xf')](_0x27af('0x21'),_0xd501da,JSON[_0x27af('0x11')](_0x4051f5));_0x56cf16(_0x4051f5);})['catch'](function(_0x41cbd8){logger[_0x27af('0x12')](_0x27af('0x21'),_0x41cbd8[_0x27af('0x14')],_0xd501da);_0x10a293(_0x5be9f5[_0x27af('0x12')](0x1f4,_0x41cbd8[_0x27af('0x14')]));});});};exports[_0x27af('0x23')]=function(_0x4f0e1b){var _0x2ed9c1=this;return new Promise(function(_0x2b5981,_0x95ead9){return db[_0x27af('0x22')]['update'](_0x4f0e1b[_0x27af('0x24')],{'raw':_0x4f0e1b[_0x27af('0x18')]?_0x4f0e1b['options'][_0x27af('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4f0e1b[_0x27af('0x18')]?_0x4f0e1b[_0x27af('0x18')]['where']||null:null,'attributes':_0x4f0e1b[_0x27af('0x18')]?_0x4f0e1b[_0x27af('0x18')][_0x27af('0x1b')]||null:null,'limit':_0x4f0e1b[_0x27af('0x18')]?_0x4f0e1b['options']['limit']||null:null})[_0x27af('0x25')](function(_0x3646d6){logger['info']('UpdateVoiceQueueReport',_0x4f0e1b);logger[_0x27af('0xf')](_0x27af('0x23'),_0x4f0e1b,JSON[_0x27af('0x11')](_0x3646d6));_0x2b5981(_0x3646d6);})[_0x27af('0x16')](function(_0x5d5853){logger[_0x27af('0x12')](_0x27af('0x23'),_0x5d5853[_0x27af('0x14')],_0x4f0e1b);_0x95ead9(_0x2ed9c1[_0x27af('0x12')](0x1f4,_0x5d5853[_0x27af('0x14')]));});});};