3a226529eee9896f27513f2adb82c9c6222dcea8
[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 _0x11ea=['message','catch','GetVoiceQueueReport','VoiceQueueReport','findAll','options','where','attributes','limit','map','include','model','debug','CreateVoiceQueueReport','body','raw','UpdateVoiceQueueReport','update','util','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','http','redis','localhost','socket.io-emitter','then','info','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x43b22b,_0xea722c){var _0xd4e124=function(_0x271814){while(--_0x271814){_0x43b22b['push'](_0x43b22b['shift']());}};_0xd4e124(++_0xea722c);}(_0x11ea,0x132));var _0xa11e=function(_0x3df853,_0x28a02c){_0x3df853=_0x3df853-0x0;var _0x101de3=_0x11ea[_0x3df853];return _0x101de3;};'use strict';var _=require('lodash');var util=require(_0xa11e('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xa11e('0x1'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xa11e('0x2'));var logger=require(_0xa11e('0x3'))(_0xa11e('0x4'));var config=require(_0xa11e('0x5'));var jayson=require('jayson/promise');var client=jayson['client'][_0xa11e('0x6')]({'port':0x232a});config[_0xa11e('0x7')]=_['defaults'](config[_0xa11e('0x7')],{'host':_0xa11e('0x8'),'port':0x18eb});var socket=require(_0xa11e('0x9'))(new Redis(config['redis']));require('./voiceQueueReport.socket')['register'](socket);function respondWithRpcPromise(_0x41821b,_0xa14320,_0x17d300){return new BPromise(function(_0xec744c,_0x394853){return client['request'](_0x41821b,_0x17d300)[_0xa11e('0xa')](function(_0x458b7c){logger[_0xa11e('0xb')](_0xa11e('0xc'),_0xa14320,_0xa11e('0xd'));logger['debug'](_0xa11e('0xe'),_0xa14320,_0xa11e('0xd'),JSON[_0xa11e('0xf')](_0x458b7c));if(_0x458b7c[_0xa11e('0x10')]){if(_0x458b7c['error'][_0xa11e('0x11')]===0x1f4){logger[_0xa11e('0x10')](_0xa11e('0xc'),_0xa14320,_0x458b7c[_0xa11e('0x10')][_0xa11e('0x12')]);return _0x394853(_0x458b7c[_0xa11e('0x10')][_0xa11e('0x12')]);}logger[_0xa11e('0x10')]('VoiceQueueReport,\x20%s,\x20%s',_0xa14320,_0x458b7c[_0xa11e('0x10')][_0xa11e('0x12')]);return _0xec744c(_0x458b7c[_0xa11e('0x10')]['message']);}else{logger[_0xa11e('0xb')](_0xa11e('0xc'),_0xa14320,_0xa11e('0xd'));_0xec744c(_0x458b7c['result']['message']);}})[_0xa11e('0x13')](function(_0x2ae480){logger[_0xa11e('0x10')](_0xa11e('0xc'),_0xa14320,_0x2ae480);_0x394853(_0x2ae480);});});}exports[_0xa11e('0x14')]=function(_0x1b6c37){var _0x12f33d=this;return new Promise(function(_0x2fe467,_0x1d1a23){return db[_0xa11e('0x15')][_0xa11e('0x16')]({'raw':_0x1b6c37[_0xa11e('0x17')]?_0x1b6c37['options']['raw']===undefined?!![]:![]:!![],'where':_0x1b6c37[_0xa11e('0x17')]?_0x1b6c37[_0xa11e('0x17')][_0xa11e('0x18')]||null:null,'attributes':_0x1b6c37[_0xa11e('0x17')]?_0x1b6c37[_0xa11e('0x17')][_0xa11e('0x19')]||null:null,'limit':_0x1b6c37[_0xa11e('0x17')]?_0x1b6c37[_0xa11e('0x17')][_0xa11e('0x1a')]||null:null,'include':_0x1b6c37[_0xa11e('0x17')]?_0x1b6c37['options']['include']?_[_0xa11e('0x1b')](_0x1b6c37[_0xa11e('0x17')][_0xa11e('0x1c')],function(_0x1296a7){return{'model':db[_0x1296a7[_0xa11e('0x1d')]],'as':_0x1296a7['as'],'attributes':_0x1296a7[_0xa11e('0x19')],'include':_0x1296a7[_0xa11e('0x1c')]?_[_0xa11e('0x1b')](_0x1296a7['include'],function(_0x14ed24){return{'model':db[_0x14ed24['model']],'as':_0x14ed24['as'],'attributes':_0x14ed24[_0xa11e('0x19')],'include':_0x14ed24[_0xa11e('0x1c')]?_[_0xa11e('0x1b')](_0x14ed24[_0xa11e('0x1c')],function(_0x405e3e){return{'model':db[_0x405e3e[_0xa11e('0x1d')]],'as':_0x405e3e['as'],'attributes':_0x405e3e[_0xa11e('0x19')]};}):[]};}):[]};}):[]:[]})[_0xa11e('0xa')](function(_0x23d50a){logger['info']('GetVoiceQueueReport',_0x1b6c37);logger[_0xa11e('0x1e')](_0xa11e('0x14'),_0x1b6c37,JSON[_0xa11e('0xf')](_0x23d50a));_0x2fe467(_0x23d50a);})['catch'](function(_0x48dd9c){logger['error'](_0xa11e('0x14'),_0x48dd9c[_0xa11e('0x12')],_0x1b6c37);_0x1d1a23(_0x12f33d[_0xa11e('0x10')](0x1f4,_0x48dd9c[_0xa11e('0x12')]));});});};exports[_0xa11e('0x1f')]=function(_0xc85aa4){var _0x263c97=this;return new Promise(function(_0x3120c3,_0x2f97ed){return db[_0xa11e('0x15')]['create'](_0xc85aa4[_0xa11e('0x20')],{'raw':_0xc85aa4[_0xa11e('0x17')]?_0xc85aa4['options'][_0xa11e('0x21')]===undefined?!![]:![]:!![]})[_0xa11e('0xa')](function(_0x108458){logger[_0xa11e('0xb')]('CreateVoiceQueueReport',_0xc85aa4);logger[_0xa11e('0x1e')](_0xa11e('0x1f'),_0xc85aa4,JSON['stringify'](_0x108458));_0x3120c3(_0x108458);})[_0xa11e('0x13')](function(_0x297d7e){logger[_0xa11e('0x10')](_0xa11e('0x1f'),_0x297d7e[_0xa11e('0x12')],_0xc85aa4);_0x2f97ed(_0x263c97[_0xa11e('0x10')](0x1f4,_0x297d7e[_0xa11e('0x12')]));});});};exports[_0xa11e('0x22')]=function(_0x49fae5){var _0x373de8=this;return new Promise(function(_0x5076d4,_0x44eabf){return db['VoiceQueueReport'][_0xa11e('0x23')](_0x49fae5[_0xa11e('0x20')],{'raw':_0x49fae5[_0xa11e('0x17')]?_0x49fae5['options'][_0xa11e('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x49fae5[_0xa11e('0x17')]?_0x49fae5[_0xa11e('0x17')][_0xa11e('0x18')]||null:null,'attributes':_0x49fae5['options']?_0x49fae5[_0xa11e('0x17')][_0xa11e('0x19')]||null:null,'limit':_0x49fae5[_0xa11e('0x17')]?_0x49fae5[_0xa11e('0x17')][_0xa11e('0x1a')]||null:null})[_0xa11e('0xa')](function(_0x5a1fd5){logger[_0xa11e('0xb')](_0xa11e('0x22'),_0x49fae5);logger[_0xa11e('0x1e')]('UpdateVoiceQueueReport',_0x49fae5,JSON['stringify'](_0x5a1fd5));_0x5076d4(_0x5a1fd5);})[_0xa11e('0x13')](function(_0x1e89ed){logger[_0xa11e('0x10')](_0xa11e('0x22'),_0x1e89ed[_0xa11e('0x12')],_0x49fae5);_0x44eabf(_0x373de8['error'](0x1f4,_0x1e89ed[_0xa11e('0x12')]));});});};