5c7654a03dfff5a07f1db1ba0d77c95ff405f3f8
[motion2.git] / server / api / whatsappQueueReport / whatsappQueueReport.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 _0x2e6c=['CreateWhatsappQueueReport','UpdateWhatsappQueueReport','body','attributes','limit','lodash','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','http','request','info','WhatsappQueueReport,\x20%s,\x20%s','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','WhatsappQueueReport','create','options','raw','then'];(function(_0x8a390b,_0x4fea60){var _0x5aade9=function(_0x4338c2){while(--_0x4338c2){_0x8a390b['push'](_0x8a390b['shift']());}};_0x5aade9(++_0x4fea60);}(_0x2e6c,0xf5));var _0xc2e6=function(_0x59ee6f,_0x450239){_0x59ee6f=_0x59ee6f-0x0;var _0x4c0979=_0x2e6c[_0x59ee6f];return _0x4c0979;};'use strict';var _=require(_0xc2e6('0x0'));var util=require('util');var moment=require(_0xc2e6('0x1'));var BPromise=require(_0xc2e6('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc2e6('0x3'))['db'];var utils=require(_0xc2e6('0x4'));var logger=require(_0xc2e6('0x5'))('rpc');var config=require(_0xc2e6('0x6'));var jayson=require('jayson/promise');var client=jayson['client'][_0xc2e6('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x5f46e1,_0x26fa85,_0xe9f5b0){return new BPromise(function(_0x5ae797,_0x5deae4){return client[_0xc2e6('0x8')](_0x5f46e1,_0xe9f5b0)['then'](function(_0x3f3254){logger[_0xc2e6('0x9')](_0xc2e6('0xa'),_0x26fa85,'request\x20sent');logger[_0xc2e6('0xb')](_0xc2e6('0xc'),_0x26fa85,_0xc2e6('0xd'),JSON[_0xc2e6('0xe')](_0x3f3254));if(_0x3f3254[_0xc2e6('0xf')]){if(_0x3f3254[_0xc2e6('0xf')][_0xc2e6('0x10')]===0x1f4){logger[_0xc2e6('0xf')](_0xc2e6('0xa'),_0x26fa85,_0x3f3254['error'][_0xc2e6('0x11')]);return _0x5deae4(_0x3f3254[_0xc2e6('0xf')][_0xc2e6('0x11')]);}logger['error'](_0xc2e6('0xa'),_0x26fa85,_0x3f3254[_0xc2e6('0xf')]['message']);return _0x5ae797(_0x3f3254['error'][_0xc2e6('0x11')]);}else{logger[_0xc2e6('0x9')]('WhatsappQueueReport,\x20%s,\x20%s',_0x26fa85,_0xc2e6('0xd'));_0x5ae797(_0x3f3254[_0xc2e6('0x12')]['message']);}})[_0xc2e6('0x13')](function(_0x80a215){logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0x26fa85,_0x80a215);_0x5deae4(_0x80a215);});});}exports['CreateWhatsappQueueReport']=function(_0x196b2e){var _0x45c4d2=this;return new Promise(function(_0x5303e8,_0x22e5b5){return db[_0xc2e6('0x14')][_0xc2e6('0x15')](_0x196b2e['body'],{'raw':_0x196b2e[_0xc2e6('0x16')]?_0x196b2e[_0xc2e6('0x16')][_0xc2e6('0x17')]===undefined?!![]:![]:!![]})[_0xc2e6('0x18')](function(_0x44c90c){logger[_0xc2e6('0x9')]('CreateWhatsappQueueReport',_0x196b2e);logger['debug']('CreateWhatsappQueueReport',_0x196b2e,JSON[_0xc2e6('0xe')](_0x44c90c));_0x5303e8(_0x44c90c);})['catch'](function(_0xc4ee3f){logger[_0xc2e6('0xf')](_0xc2e6('0x19'),_0xc4ee3f['message'],_0x196b2e);_0x22e5b5(_0x45c4d2[_0xc2e6('0xf')](0x1f4,_0xc4ee3f['message']));});});};exports[_0xc2e6('0x1a')]=function(_0x54d171){var _0x199cb4=this;return new Promise(function(_0x4af3cd,_0x218d58){return db[_0xc2e6('0x14')]['update'](_0x54d171[_0xc2e6('0x1b')],{'raw':_0x54d171[_0xc2e6('0x16')]?_0x54d171[_0xc2e6('0x16')][_0xc2e6('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x54d171[_0xc2e6('0x16')]?_0x54d171[_0xc2e6('0x16')]['where']||null:null,'attributes':_0x54d171['options']?_0x54d171[_0xc2e6('0x16')][_0xc2e6('0x1c')]||null:null,'limit':_0x54d171[_0xc2e6('0x16')]?_0x54d171[_0xc2e6('0x16')][_0xc2e6('0x1d')]||null:null})[_0xc2e6('0x18')](function(_0x30eb21){logger[_0xc2e6('0x9')](_0xc2e6('0x1a'),_0x54d171);logger['debug'](_0xc2e6('0x1a'),_0x54d171,JSON[_0xc2e6('0xe')](_0x30eb21));_0x4af3cd(_0x30eb21);})['catch'](function(_0x2efb56){logger[_0xc2e6('0xf')]('UpdateWhatsappQueueReport',_0x2efb56['message'],_0x54d171);_0x218d58(_0x199cb4['error'](0x1f4,_0x2efb56[_0xc2e6('0x11')]));});});};