f47f2e449fe85089e12e1e6d13a5a7cb97c93866
[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 _0x0f64=['body','UpdateVoiceQueueReport','update','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','then','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetVoiceQueueReport','VoiceQueueReport','findAll','options','where','attributes','limit','include','model','map','CreateVoiceQueueReport','create'];(function(_0x3f993e,_0x2d5757){var _0x39c135=function(_0x39e00b){while(--_0x39e00b){_0x3f993e['push'](_0x3f993e['shift']());}};_0x39c135(++_0x2d5757);}(_0x0f64,0x143));var _0x40f6=function(_0xd85e0f,_0x585f36){_0xd85e0f=_0xd85e0f-0x0;var _0x46febd=_0x0f64[_0xd85e0f];return _0x46febd;};'use strict';var _=require(_0x40f6('0x0'));var util=require('util');var moment=require(_0x40f6('0x1'));var BPromise=require(_0x40f6('0x2'));var rs=require(_0x40f6('0x3'));var fs=require('fs');var Redis=require(_0x40f6('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x40f6('0x5'));var logger=require(_0x40f6('0x6'))(_0x40f6('0x7'));var config=require('../../config/environment');var jayson=require(_0x40f6('0x8'));var client=jayson['client'][_0x40f6('0x9')]({'port':0x232a});config[_0x40f6('0xa')]=_[_0x40f6('0xb')](config[_0x40f6('0xa')],{'host':_0x40f6('0xc'),'port':0x18eb});var socket=require(_0x40f6('0xd'))(new Redis(config[_0x40f6('0xa')]));require('./voiceQueueReport.socket')['register'](socket);function respondWithRpcPromise(_0x5ad309,_0x3c56a7,_0x1c4aa1){return new BPromise(function(_0x46ee2f,_0x552146){return client['request'](_0x5ad309,_0x1c4aa1)[_0x40f6('0xe')](function(_0x1ff81e){logger[_0x40f6('0xf')](_0x40f6('0x10'),_0x3c56a7,_0x40f6('0x11'));logger[_0x40f6('0x12')](_0x40f6('0x13'),_0x3c56a7,_0x40f6('0x11'),JSON['stringify'](_0x1ff81e));if(_0x1ff81e[_0x40f6('0x14')]){if(_0x1ff81e[_0x40f6('0x14')][_0x40f6('0x15')]===0x1f4){logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0x3c56a7,_0x1ff81e[_0x40f6('0x14')][_0x40f6('0x16')]);return _0x552146(_0x1ff81e[_0x40f6('0x14')][_0x40f6('0x16')]);}logger[_0x40f6('0x14')](_0x40f6('0x10'),_0x3c56a7,_0x1ff81e[_0x40f6('0x14')][_0x40f6('0x16')]);return _0x46ee2f(_0x1ff81e[_0x40f6('0x14')][_0x40f6('0x16')]);}else{logger[_0x40f6('0xf')](_0x40f6('0x10'),_0x3c56a7,'request\x20sent');_0x46ee2f(_0x1ff81e[_0x40f6('0x17')][_0x40f6('0x16')]);}})[_0x40f6('0x18')](function(_0xa23e43){logger[_0x40f6('0x14')](_0x40f6('0x10'),_0x3c56a7,_0xa23e43);_0x552146(_0xa23e43);});});}exports[_0x40f6('0x19')]=function(_0x4d775e){var _0x268c07=this;return new Promise(function(_0x256f91,_0x56fe51){return db[_0x40f6('0x1a')][_0x40f6('0x1b')]({'raw':_0x4d775e['options']?_0x4d775e[_0x40f6('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x4d775e[_0x40f6('0x1c')]?_0x4d775e[_0x40f6('0x1c')][_0x40f6('0x1d')]||null:null,'attributes':_0x4d775e[_0x40f6('0x1c')]?_0x4d775e[_0x40f6('0x1c')][_0x40f6('0x1e')]||null:null,'limit':_0x4d775e[_0x40f6('0x1c')]?_0x4d775e[_0x40f6('0x1c')][_0x40f6('0x1f')]||null:null,'include':_0x4d775e[_0x40f6('0x1c')]?_0x4d775e['options'][_0x40f6('0x20')]?_['map'](_0x4d775e[_0x40f6('0x1c')][_0x40f6('0x20')],function(_0x5590b7){return{'model':db[_0x5590b7[_0x40f6('0x21')]],'as':_0x5590b7['as'],'attributes':_0x5590b7[_0x40f6('0x1e')],'include':_0x5590b7['include']?_[_0x40f6('0x22')](_0x5590b7[_0x40f6('0x20')],function(_0x28bc00){return{'model':db[_0x28bc00[_0x40f6('0x21')]],'as':_0x28bc00['as'],'attributes':_0x28bc00[_0x40f6('0x1e')],'include':_0x28bc00[_0x40f6('0x20')]?_[_0x40f6('0x22')](_0x28bc00[_0x40f6('0x20')],function(_0x50d567){return{'model':db[_0x50d567['model']],'as':_0x50d567['as'],'attributes':_0x50d567[_0x40f6('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x40f6('0xe')](function(_0x1e707a){logger[_0x40f6('0xf')]('GetVoiceQueueReport',_0x4d775e);logger[_0x40f6('0x12')](_0x40f6('0x19'),_0x4d775e,JSON['stringify'](_0x1e707a));_0x256f91(_0x1e707a);})[_0x40f6('0x18')](function(_0x17d93b){logger[_0x40f6('0x14')]('GetVoiceQueueReport',_0x17d93b['message'],_0x4d775e);_0x56fe51(_0x268c07[_0x40f6('0x14')](0x1f4,_0x17d93b['message']));});});};exports[_0x40f6('0x23')]=function(_0x4aa83e){var _0x3629fb=this;return new Promise(function(_0x397558,_0x1f7608){return db[_0x40f6('0x1a')][_0x40f6('0x24')](_0x4aa83e[_0x40f6('0x25')],{'raw':_0x4aa83e[_0x40f6('0x1c')]?_0x4aa83e[_0x40f6('0x1c')]['raw']===undefined?!![]:![]:!![]})[_0x40f6('0xe')](function(_0x477216){logger[_0x40f6('0xf')]('CreateVoiceQueueReport',_0x4aa83e);logger['debug'](_0x40f6('0x23'),_0x4aa83e,JSON['stringify'](_0x477216));_0x397558(_0x477216);})[_0x40f6('0x18')](function(_0x3bf718){logger['error'](_0x40f6('0x23'),_0x3bf718['message'],_0x4aa83e);_0x1f7608(_0x3629fb[_0x40f6('0x14')](0x1f4,_0x3bf718[_0x40f6('0x16')]));});});};exports[_0x40f6('0x26')]=function(_0x2c2f51){var _0x4caffd=this;return new Promise(function(_0x5f361d,_0xa1c3e3){return db['VoiceQueueReport'][_0x40f6('0x27')](_0x2c2f51[_0x40f6('0x25')],{'raw':_0x2c2f51[_0x40f6('0x1c')]?_0x2c2f51['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2c2f51['options']?_0x2c2f51['options'][_0x40f6('0x1d')]||null:null,'attributes':_0x2c2f51[_0x40f6('0x1c')]?_0x2c2f51[_0x40f6('0x1c')][_0x40f6('0x1e')]||null:null,'limit':_0x2c2f51['options']?_0x2c2f51[_0x40f6('0x1c')][_0x40f6('0x1f')]||null:null})[_0x40f6('0xe')](function(_0x1fe5f0){logger[_0x40f6('0xf')](_0x40f6('0x26'),_0x2c2f51);logger[_0x40f6('0x12')](_0x40f6('0x26'),_0x2c2f51,JSON['stringify'](_0x1fe5f0));_0x5f361d(_0x1fe5f0);})[_0x40f6('0x18')](function(_0x38056b){logger[_0x40f6('0x14')](_0x40f6('0x26'),_0x38056b[_0x40f6('0x16')],_0x2c2f51);_0xa1c3e3(_0x4caffd['error'](0x1f4,_0x38056b['message']));});});};