7ef6ef2de44a5d668422dfe35676808ae652b41b
[motion2.git] / server / api / openchannelQueueReport / openchannelQueueReport.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 _0x1d0a=['where','attributes','limit','UpdateOpenchannelQueueReport','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','client','http','info','OpenchannelQueueReport,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','OpenchannelQueueReport','create','body','options','raw','then','CreateOpenchannelQueueReport','catch'];(function(_0x209ec9,_0x30378c){var _0x129b1b=function(_0x2f2b9e){while(--_0x2f2b9e){_0x209ec9['push'](_0x209ec9['shift']());}};_0x129b1b(++_0x30378c);}(_0x1d0a,0x17d));var _0xa1d0=function(_0x4b1501,_0x3267b0){_0x4b1501=_0x4b1501-0x0;var _0x5f4dd4=_0x1d0a[_0x4b1501];return _0x5f4dd4;};'use strict';var _=require(_0xa1d0('0x0'));var util=require(_0xa1d0('0x1'));var moment=require(_0xa1d0('0x2'));var BPromise=require(_0xa1d0('0x3'));var rs=require(_0xa1d0('0x4'));var fs=require('fs');var Redis=require(_0xa1d0('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xa1d0('0x6'))(_0xa1d0('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xa1d0('0x8')][_0xa1d0('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4021dd,_0x5c3656,_0xda24f4){return new BPromise(function(_0x58478e,_0x2bf294){return client['request'](_0x4021dd,_0xda24f4)['then'](function(_0x191002){logger[_0xa1d0('0xa')](_0xa1d0('0xb'),_0x5c3656,_0xa1d0('0xc'));logger[_0xa1d0('0xd')]('OpenchannelQueueReport,\x20%s,\x20%s,\x20%s',_0x5c3656,'request\x20sent',JSON[_0xa1d0('0xe')](_0x191002));if(_0x191002['error']){if(_0x191002[_0xa1d0('0xf')]['code']===0x1f4){logger[_0xa1d0('0xf')](_0xa1d0('0xb'),_0x5c3656,_0x191002[_0xa1d0('0xf')][_0xa1d0('0x10')]);return _0x2bf294(_0x191002['error']['message']);}logger['error'](_0xa1d0('0xb'),_0x5c3656,_0x191002[_0xa1d0('0xf')][_0xa1d0('0x10')]);return _0x58478e(_0x191002['error']['message']);}else{logger['info'](_0xa1d0('0xb'),_0x5c3656,_0xa1d0('0xc'));_0x58478e(_0x191002['result'][_0xa1d0('0x10')]);}})['catch'](function(_0x5251d0){logger[_0xa1d0('0xf')](_0xa1d0('0xb'),_0x5c3656,_0x5251d0);_0x2bf294(_0x5251d0);});});}exports['CreateOpenchannelQueueReport']=function(_0x3a4c1d){var _0x50c1fe=this;return new Promise(function(_0x4d5377,_0x39f509){return db[_0xa1d0('0x11')][_0xa1d0('0x12')](_0x3a4c1d[_0xa1d0('0x13')],{'raw':_0x3a4c1d[_0xa1d0('0x14')]?_0x3a4c1d[_0xa1d0('0x14')][_0xa1d0('0x15')]===undefined?!![]:![]:!![]})[_0xa1d0('0x16')](function(_0x47d4d9){logger['info']('CreateOpenchannelQueueReport',_0x3a4c1d);logger['debug'](_0xa1d0('0x17'),_0x3a4c1d,JSON[_0xa1d0('0xe')](_0x47d4d9));_0x4d5377(_0x47d4d9);})[_0xa1d0('0x18')](function(_0x215376){logger[_0xa1d0('0xf')](_0xa1d0('0x17'),_0x215376[_0xa1d0('0x10')],_0x3a4c1d);_0x39f509(_0x50c1fe[_0xa1d0('0xf')](0x1f4,_0x215376['message']));});});};exports['UpdateOpenchannelQueueReport']=function(_0x570392){var _0x447b72=this;return new Promise(function(_0x16aeb8,_0xb91d5){return db[_0xa1d0('0x11')]['update'](_0x570392['body'],{'raw':_0x570392[_0xa1d0('0x14')]?_0x570392[_0xa1d0('0x14')][_0xa1d0('0x15')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x570392[_0xa1d0('0x14')]?_0x570392[_0xa1d0('0x14')][_0xa1d0('0x19')]||null:null,'attributes':_0x570392[_0xa1d0('0x14')]?_0x570392[_0xa1d0('0x14')][_0xa1d0('0x1a')]||null:null,'limit':_0x570392[_0xa1d0('0x14')]?_0x570392['options'][_0xa1d0('0x1b')]||null:null})['then'](function(_0x4dfbae){logger[_0xa1d0('0xa')](_0xa1d0('0x1c'),_0x570392);logger[_0xa1d0('0xd')](_0xa1d0('0x1c'),_0x570392,JSON['stringify'](_0x4dfbae));_0x16aeb8(_0x4dfbae);})[_0xa1d0('0x18')](function(_0x4df589){logger[_0xa1d0('0xf')]('UpdateOpenchannelQueueReport',_0x4df589[_0xa1d0('0x10')],_0x570392);_0xb91d5(_0x447b72['error'](0x1f4,_0x4df589[_0xa1d0('0x10')]));});});};