Built motion from commit (unavailable).|2.4.20
[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 _0x630e=['../../config/environment','client','localhost','redis','./voiceQueueReport.socket','register','request','info','request\x20sent','debug','VoiceQueueReport,\x20%s,\x20%s,\x20%s','stringify','VoiceQueueReport,\x20%s,\x20%s','error','message','result','catch','GetVoiceQueueReport','findAll','options','raw','where','attributes','limit','include','map','model','CreateVoiceQueueReport','VoiceQueueReport','create','update','body','then','UpdateVoiceQueueReport','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x54ce4a,_0x502cba){var _0x279dce=function(_0x217ed8){while(--_0x217ed8){_0x54ce4a['push'](_0x54ce4a['shift']());}};_0x279dce(++_0x502cba);}(_0x630e,0x1e5));var _0xe630=function(_0x18480c,_0x2a940c){_0x18480c=_0x18480c-0x0;var _0x43b4b0=_0x630e[_0x18480c];return _0x43b4b0;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xe630('0x0'));var BPromise=require(_0xe630('0x1'));var rs=require(_0xe630('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xe630('0x3'))['db'];var utils=require(_0xe630('0x4'));var logger=require(_0xe630('0x5'))(_0xe630('0x6'));var config=require(_0xe630('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xe630('0x8')]['http']({'port':0x232a});config['redis']=_['defaults'](config['redis'],{'host':_0xe630('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xe630('0xa')]));require(_0xe630('0xb'))[_0xe630('0xc')](socket);function respondWithRpcPromise(_0x4353d9,_0x5c98c9,_0x5d6d55){return new BPromise(function(_0x1ddab7,_0x299c30){return client[_0xe630('0xd')](_0x4353d9,_0x5d6d55)['then'](function(_0x220df9){logger[_0xe630('0xe')]('VoiceQueueReport,\x20%s,\x20%s',_0x5c98c9,_0xe630('0xf'));logger[_0xe630('0x10')](_0xe630('0x11'),_0x5c98c9,_0xe630('0xf'),JSON[_0xe630('0x12')](_0x220df9));if(_0x220df9['error']){if(_0x220df9['error']['code']===0x1f4){logger['error'](_0xe630('0x13'),_0x5c98c9,_0x220df9[_0xe630('0x14')][_0xe630('0x15')]);return _0x299c30(_0x220df9[_0xe630('0x14')]['message']);}logger['error'](_0xe630('0x13'),_0x5c98c9,_0x220df9[_0xe630('0x14')]['message']);return _0x1ddab7(_0x220df9[_0xe630('0x14')][_0xe630('0x15')]);}else{logger[_0xe630('0xe')](_0xe630('0x13'),_0x5c98c9,_0xe630('0xf'));_0x1ddab7(_0x220df9[_0xe630('0x16')][_0xe630('0x15')]);}})[_0xe630('0x17')](function(_0x4c88a4){logger['error']('VoiceQueueReport,\x20%s,\x20%s',_0x5c98c9,_0x4c88a4);_0x299c30(_0x4c88a4);});});}exports[_0xe630('0x18')]=function(_0x130b6f){var _0x381d69=this;return new Promise(function(_0x2b72d7,_0x11879b){return db['VoiceQueueReport'][_0xe630('0x19')]({'raw':_0x130b6f[_0xe630('0x1a')]?_0x130b6f[_0xe630('0x1a')][_0xe630('0x1b')]===undefined?!![]:![]:!![],'where':_0x130b6f[_0xe630('0x1a')]?_0x130b6f[_0xe630('0x1a')][_0xe630('0x1c')]||null:null,'attributes':_0x130b6f[_0xe630('0x1a')]?_0x130b6f['options'][_0xe630('0x1d')]||null:null,'limit':_0x130b6f[_0xe630('0x1a')]?_0x130b6f[_0xe630('0x1a')][_0xe630('0x1e')]||null:null,'include':_0x130b6f[_0xe630('0x1a')]?_0x130b6f[_0xe630('0x1a')][_0xe630('0x1f')]?_[_0xe630('0x20')](_0x130b6f[_0xe630('0x1a')][_0xe630('0x1f')],function(_0x182dcc){return{'model':db[_0x182dcc['model']],'as':_0x182dcc['as'],'attributes':_0x182dcc[_0xe630('0x1d')],'include':_0x182dcc[_0xe630('0x1f')]?_[_0xe630('0x20')](_0x182dcc['include'],function(_0x94ecf8){return{'model':db[_0x94ecf8[_0xe630('0x21')]],'as':_0x94ecf8['as'],'attributes':_0x94ecf8[_0xe630('0x1d')],'include':_0x94ecf8[_0xe630('0x1f')]?_['map'](_0x94ecf8[_0xe630('0x1f')],function(_0x305eeb){return{'model':db[_0x305eeb['model']],'as':_0x305eeb['as'],'attributes':_0x305eeb[_0xe630('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x585987){logger[_0xe630('0xe')](_0xe630('0x18'),_0x130b6f);logger[_0xe630('0x10')](_0xe630('0x18'),_0x130b6f,JSON[_0xe630('0x12')](_0x585987));_0x2b72d7(_0x585987);})[_0xe630('0x17')](function(_0x226882){logger[_0xe630('0x14')](_0xe630('0x18'),_0x226882[_0xe630('0x15')],_0x130b6f);_0x11879b(_0x381d69[_0xe630('0x14')](0x1f4,_0x226882[_0xe630('0x15')]));});});};exports[_0xe630('0x22')]=function(_0x5a6942){var _0x12868a=this;return new Promise(function(_0x2dbccd,_0x31129d){return db[_0xe630('0x23')][_0xe630('0x24')](_0x5a6942['body'],{'raw':_0x5a6942[_0xe630('0x1a')]?_0x5a6942[_0xe630('0x1a')][_0xe630('0x1b')]===undefined?!![]:![]:!![]})['then'](function(_0x15e351){logger[_0xe630('0xe')]('CreateVoiceQueueReport',_0x5a6942);logger['debug'](_0xe630('0x22'),_0x5a6942,JSON[_0xe630('0x12')](_0x15e351));_0x2dbccd(_0x15e351);})[_0xe630('0x17')](function(_0x5acaf2){logger[_0xe630('0x14')](_0xe630('0x22'),_0x5acaf2[_0xe630('0x15')],_0x5a6942);_0x31129d(_0x12868a['error'](0x1f4,_0x5acaf2[_0xe630('0x15')]));});});};exports['UpdateVoiceQueueReport']=function(_0x4ca199){var _0x6690f2=this;return new Promise(function(_0x2b79d0,_0x5461b7){return db[_0xe630('0x23')][_0xe630('0x25')](_0x4ca199[_0xe630('0x26')],{'raw':_0x4ca199['options']?_0x4ca199[_0xe630('0x1a')][_0xe630('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4ca199[_0xe630('0x1a')]?_0x4ca199[_0xe630('0x1a')][_0xe630('0x1c')]||null:null,'attributes':_0x4ca199[_0xe630('0x1a')]?_0x4ca199['options'][_0xe630('0x1d')]||null:null,'limit':_0x4ca199[_0xe630('0x1a')]?_0x4ca199[_0xe630('0x1a')]['limit']||null:null})[_0xe630('0x27')](function(_0x154199){logger['info'](_0xe630('0x28'),_0x4ca199);logger[_0xe630('0x10')]('UpdateVoiceQueueReport',_0x4ca199,JSON['stringify'](_0x154199));_0x2b79d0(_0x154199);})[_0xe630('0x17')](function(_0x4e191a){logger[_0xe630('0x14')](_0xe630('0x28'),_0x4e191a[_0xe630('0x15')],_0x4ca199);_0x5461b7(_0x6690f2[_0xe630('0x14')](0x1f4,_0x4e191a['message']));});});};