b789ae82cc0a1b9bb83da68b2c77b3e8c5b19e4e
[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 _0x28df=['catch','UpdateVoiceQueueReport','lodash','util','moment','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','request','info','VoiceQueueReport,\x20%s,\x20%s','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent','VoiceQueueReport','findAll','options','where','attributes','model','include','map','GetVoiceQueueReport','CreateVoiceQueueReport','create','body','raw','then'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x28df,0xca));var _0xf28d=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x28df[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0xf28d('0x0'));var util=require(_0xf28d('0x1'));var moment=require(_0xf28d('0x2'));var BPromise=require('bluebird');var rs=require(_0xf28d('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xf28d('0x4'));var logger=require(_0xf28d('0x5'))(_0xf28d('0x6'));var config=require(_0xf28d('0x7'));var jayson=require(_0xf28d('0x8'));var client=jayson[_0xf28d('0x9')][_0xf28d('0xa')]({'port':0x232a});config[_0xf28d('0xb')]=_[_0xf28d('0xc')](config['redis'],{'host':_0xf28d('0xd'),'port':0x18eb});var socket=require(_0xf28d('0xe'))(new Redis(config[_0xf28d('0xb')]));require('./voiceQueueReport.socket')['register'](socket);function respondWithRpcPromise(_0x28cbef,_0x1da597,_0x1f9765){return new BPromise(function(_0x625c5f,_0x5a6b58){return client[_0xf28d('0xf')](_0x28cbef,_0x1f9765)['then'](function(_0x369bc8){logger[_0xf28d('0x10')](_0xf28d('0x11'),_0x1da597,'request\x20sent');logger[_0xf28d('0x12')](_0xf28d('0x13'),_0x1da597,'request\x20sent',JSON[_0xf28d('0x14')](_0x369bc8));if(_0x369bc8[_0xf28d('0x15')]){if(_0x369bc8[_0xf28d('0x15')]['code']===0x1f4){logger[_0xf28d('0x15')](_0xf28d('0x11'),_0x1da597,_0x369bc8[_0xf28d('0x15')][_0xf28d('0x16')]);return _0x5a6b58(_0x369bc8['error'][_0xf28d('0x16')]);}logger['error'](_0xf28d('0x11'),_0x1da597,_0x369bc8[_0xf28d('0x15')]['message']);return _0x625c5f(_0x369bc8[_0xf28d('0x15')][_0xf28d('0x16')]);}else{logger['info'](_0xf28d('0x11'),_0x1da597,_0xf28d('0x17'));_0x625c5f(_0x369bc8['result'][_0xf28d('0x16')]);}})['catch'](function(_0x4f8eff){logger[_0xf28d('0x15')](_0xf28d('0x11'),_0x1da597,_0x4f8eff);_0x5a6b58(_0x4f8eff);});});}exports['GetVoiceQueueReport']=function(_0x58aa8d){var _0x32c27c=this;return new Promise(function(_0xb64bca,_0x21b1c4){return db[_0xf28d('0x18')][_0xf28d('0x19')]({'raw':_0x58aa8d[_0xf28d('0x1a')]?_0x58aa8d[_0xf28d('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x58aa8d[_0xf28d('0x1a')]?_0x58aa8d['options'][_0xf28d('0x1b')]||null:null,'attributes':_0x58aa8d[_0xf28d('0x1a')]?_0x58aa8d[_0xf28d('0x1a')][_0xf28d('0x1c')]||null:null,'limit':_0x58aa8d[_0xf28d('0x1a')]?_0x58aa8d[_0xf28d('0x1a')]['limit']||null:null,'include':_0x58aa8d[_0xf28d('0x1a')]?_0x58aa8d[_0xf28d('0x1a')]['include']?_['map'](_0x58aa8d[_0xf28d('0x1a')]['include'],function(_0x483cd6){return{'model':db[_0x483cd6[_0xf28d('0x1d')]],'as':_0x483cd6['as'],'attributes':_0x483cd6['attributes'],'include':_0x483cd6[_0xf28d('0x1e')]?_[_0xf28d('0x1f')](_0x483cd6['include'],function(_0x10f701){return{'model':db[_0x10f701['model']],'as':_0x10f701['as'],'attributes':_0x10f701['attributes'],'include':_0x10f701[_0xf28d('0x1e')]?_[_0xf28d('0x1f')](_0x10f701[_0xf28d('0x1e')],function(_0x44c146){return{'model':db[_0x44c146[_0xf28d('0x1d')]],'as':_0x44c146['as'],'attributes':_0x44c146['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x1b487e){logger['info'](_0xf28d('0x20'),_0x58aa8d);logger[_0xf28d('0x12')](_0xf28d('0x20'),_0x58aa8d,JSON[_0xf28d('0x14')](_0x1b487e));_0xb64bca(_0x1b487e);})['catch'](function(_0x197009){logger[_0xf28d('0x15')](_0xf28d('0x20'),_0x197009[_0xf28d('0x16')],_0x58aa8d);_0x21b1c4(_0x32c27c[_0xf28d('0x15')](0x1f4,_0x197009['message']));});});};exports[_0xf28d('0x21')]=function(_0x316dbc){var _0x25227e=this;return new Promise(function(_0x3aa323,_0x185596){return db['VoiceQueueReport'][_0xf28d('0x22')](_0x316dbc[_0xf28d('0x23')],{'raw':_0x316dbc[_0xf28d('0x1a')]?_0x316dbc['options'][_0xf28d('0x24')]===undefined?!![]:![]:!![]})[_0xf28d('0x25')](function(_0x352e2d){logger['info'](_0xf28d('0x21'),_0x316dbc);logger[_0xf28d('0x12')]('CreateVoiceQueueReport',_0x316dbc,JSON[_0xf28d('0x14')](_0x352e2d));_0x3aa323(_0x352e2d);})[_0xf28d('0x26')](function(_0x9b7a80){logger['error'](_0xf28d('0x21'),_0x9b7a80[_0xf28d('0x16')],_0x316dbc);_0x185596(_0x25227e['error'](0x1f4,_0x9b7a80['message']));});});};exports[_0xf28d('0x27')]=function(_0x42582a){var _0x368c9c=this;return new Promise(function(_0x715dd7,_0x5be027){return db[_0xf28d('0x18')]['update'](_0x42582a['body'],{'raw':_0x42582a['options']?_0x42582a[_0xf28d('0x1a')][_0xf28d('0x24')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x42582a[_0xf28d('0x1a')]?_0x42582a[_0xf28d('0x1a')]['where']||null:null,'attributes':_0x42582a[_0xf28d('0x1a')]?_0x42582a[_0xf28d('0x1a')][_0xf28d('0x1c')]||null:null,'limit':_0x42582a[_0xf28d('0x1a')]?_0x42582a['options']['limit']||null:null})[_0xf28d('0x25')](function(_0x1d251f){logger['info']('UpdateVoiceQueueReport',_0x42582a);logger['debug']('UpdateVoiceQueueReport',_0x42582a,JSON[_0xf28d('0x14')](_0x1d251f));_0x715dd7(_0x1d251f);})['catch'](function(_0x22e055){logger[_0xf28d('0x15')](_0xf28d('0x27'),_0x22e055[_0xf28d('0x16')],_0x42582a);_0x5be027(_0x368c9c[_0xf28d('0x15')](0x1f4,_0x22e055[_0xf28d('0x16')]));});});};