Built motion from commit (unavailable).|2.0.82
[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 _0x8549=['findAll','options','where','limit','include','map','model','attributes','GetVoiceQueueReport','stringify','CreateVoiceQueueReport','create','raw','debug','UpdateVoiceQueueReport','body','lodash','moment','bluebird','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','client','socket.io-emitter','localhost','./voiceQueueReport.socket','register','then','VoiceQueueReport,\x20%s,\x20%s','request\x20sent','VoiceQueueReport,\x20%s,\x20%s,\x20%s','error','message','info','result','catch','VoiceQueueReport'];(function(_0x352e09,_0x37a7da){var _0x1b7094=function(_0x561074){while(--_0x561074){_0x352e09['push'](_0x352e09['shift']());}};_0x1b7094(++_0x37a7da);}(_0x8549,0xd3));var _0x9854=function(_0x114bc2,_0xd20dd3){_0x114bc2=_0x114bc2-0x0;var _0xb0b3f=_0x8549[_0x114bc2];return _0xb0b3f;};'use strict';var _=require(_0x9854('0x0'));var util=require('util');var moment=require(_0x9854('0x1'));var BPromise=require(_0x9854('0x2'));var rs=require(_0x9854('0x3'));var fs=require('fs');var db=require(_0x9854('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x9854('0x5'));var config=require(_0x9854('0x6'));var jayson=require(_0x9854('0x7'));var client=jayson[_0x9854('0x8')]['http']({'port':0x232a});var socket=require(_0x9854('0x9'))({'host':_0x9854('0xa'),'port':0x18eb});require(_0x9854('0xb'))[_0x9854('0xc')](socket);function respondWithRpcPromise(_0x2c4fdc,_0x5824de,_0x573160){return new BPromise(function(_0x146603,_0x4ac59e){return client['request'](_0x2c4fdc,_0x573160)[_0x9854('0xd')](function(_0x4faaf9){logger['info'](_0x9854('0xe'),_0x5824de,_0x9854('0xf'));logger['debug'](_0x9854('0x10'),_0x5824de,_0x9854('0xf'),JSON['stringify'](_0x4faaf9));if(_0x4faaf9[_0x9854('0x11')]){if(_0x4faaf9[_0x9854('0x11')]['code']===0x1f4){logger['error'](_0x9854('0xe'),_0x5824de,_0x4faaf9['error']['message']);return _0x4ac59e(_0x4faaf9[_0x9854('0x11')][_0x9854('0x12')]);}logger[_0x9854('0x11')](_0x9854('0xe'),_0x5824de,_0x4faaf9['error'][_0x9854('0x12')]);return _0x146603(_0x4faaf9[_0x9854('0x11')][_0x9854('0x12')]);}else{logger[_0x9854('0x13')](_0x9854('0xe'),_0x5824de,_0x9854('0xf'));_0x146603(_0x4faaf9[_0x9854('0x14')][_0x9854('0x12')]);}})[_0x9854('0x15')](function(_0x3a8607){logger[_0x9854('0x11')](_0x9854('0xe'),_0x5824de,_0x3a8607);_0x4ac59e(_0x3a8607);});});}exports['GetVoiceQueueReport']=function(_0x3f913b){var _0x4f26be=this;return new Promise(function(_0x22bb37,_0xaa943e){return db[_0x9854('0x16')][_0x9854('0x17')]({'raw':_0x3f913b[_0x9854('0x18')]?_0x3f913b['options']['raw']===undefined?!![]:![]:!![],'where':_0x3f913b['options']?_0x3f913b[_0x9854('0x18')][_0x9854('0x19')]||null:null,'attributes':_0x3f913b[_0x9854('0x18')]?_0x3f913b[_0x9854('0x18')]['attributes']||null:null,'limit':_0x3f913b[_0x9854('0x18')]?_0x3f913b[_0x9854('0x18')][_0x9854('0x1a')]||null:null,'include':_0x3f913b[_0x9854('0x18')]?_0x3f913b[_0x9854('0x18')][_0x9854('0x1b')]?_[_0x9854('0x1c')](_0x3f913b[_0x9854('0x18')][_0x9854('0x1b')],function(_0x5ef7b4){return{'model':db[_0x5ef7b4[_0x9854('0x1d')]],'as':_0x5ef7b4['as'],'attributes':_0x5ef7b4[_0x9854('0x1e')],'include':_0x5ef7b4[_0x9854('0x1b')]?_['map'](_0x5ef7b4['include'],function(_0x5da86c){return{'model':db[_0x5da86c[_0x9854('0x1d')]],'as':_0x5da86c['as'],'attributes':_0x5da86c[_0x9854('0x1e')],'include':_0x5da86c[_0x9854('0x1b')]?_['map'](_0x5da86c['include'],function(_0x478795){return{'model':db[_0x478795[_0x9854('0x1d')]],'as':_0x478795['as'],'attributes':_0x478795['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x354f6c){logger[_0x9854('0x13')](_0x9854('0x1f'),_0x3f913b);logger['debug']('GetVoiceQueueReport',_0x3f913b,JSON[_0x9854('0x20')](_0x354f6c));_0x22bb37(_0x354f6c);})[_0x9854('0x15')](function(_0x35581b){logger[_0x9854('0x11')](_0x9854('0x1f'),_0x35581b[_0x9854('0x12')],_0x3f913b);_0xaa943e(_0x4f26be['error'](0x1f4,_0x35581b[_0x9854('0x12')]));});});};exports[_0x9854('0x21')]=function(_0x5f1a85){var _0x5b8485=this;return new Promise(function(_0x187746,_0x2e460f){return db[_0x9854('0x16')][_0x9854('0x22')](_0x5f1a85['body'],{'raw':_0x5f1a85[_0x9854('0x18')]?_0x5f1a85['options'][_0x9854('0x23')]===undefined?!![]:![]:!![]})['then'](function(_0x7a898){logger[_0x9854('0x13')](_0x9854('0x21'),_0x5f1a85);logger[_0x9854('0x24')](_0x9854('0x21'),_0x5f1a85,JSON[_0x9854('0x20')](_0x7a898));_0x187746(_0x7a898);})[_0x9854('0x15')](function(_0x5a07ae){logger['error'](_0x9854('0x21'),_0x5a07ae['message'],_0x5f1a85);_0x2e460f(_0x5b8485[_0x9854('0x11')](0x1f4,_0x5a07ae[_0x9854('0x12')]));});});};exports[_0x9854('0x25')]=function(_0x17fdca){var _0x3745fd=this;return new Promise(function(_0x67424f,_0x5416b6){return db[_0x9854('0x16')]['update'](_0x17fdca[_0x9854('0x26')],{'raw':_0x17fdca['options']?_0x17fdca[_0x9854('0x18')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x17fdca[_0x9854('0x18')]?_0x17fdca[_0x9854('0x18')][_0x9854('0x19')]||null:null,'attributes':_0x17fdca['options']?_0x17fdca[_0x9854('0x18')][_0x9854('0x1e')]||null:null,'limit':_0x17fdca[_0x9854('0x18')]?_0x17fdca[_0x9854('0x18')][_0x9854('0x1a')]||null:null})[_0x9854('0xd')](function(_0x59c617){logger['info'](_0x9854('0x25'),_0x17fdca);logger[_0x9854('0x24')](_0x9854('0x25'),_0x17fdca,JSON[_0x9854('0x20')](_0x59c617));_0x67424f(_0x59c617);})[_0x9854('0x15')](function(_0x513316){logger[_0x9854('0x11')]('UpdateVoiceQueueReport',_0x513316['message'],_0x17fdca);_0x5416b6(_0x3745fd[_0x9854('0x11')](0x1f4,_0x513316[_0x9854('0x12')]));});});};