4bd219306c5c45416791181015e7e19985e4502b
[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 _0x3f99=['moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateWhatsappQueueReport','body','options','raw','UpdateWhatsappQueueReport','update','where','attributes','debug','lodash','util'];(function(_0x1d3e43,_0x2502d6){var _0x39e13e=function(_0x111d54){while(--_0x111d54){_0x1d3e43['push'](_0x1d3e43['shift']());}};_0x39e13e(++_0x2502d6);}(_0x3f99,0xa3));var _0x93f9=function(_0x4605dc,_0x3f7ae5){_0x4605dc=_0x4605dc-0x0;var _0x5d3e81=_0x3f99[_0x4605dc];return _0x5d3e81;};'use strict';var _=require(_0x93f9('0x0'));var util=require(_0x93f9('0x1'));var moment=require(_0x93f9('0x2'));var BPromise=require(_0x93f9('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x93f9('0x4'));var db=require(_0x93f9('0x5'))['db'];var utils=require(_0x93f9('0x6'));var logger=require(_0x93f9('0x7'))('rpc');var config=require(_0x93f9('0x8'));var jayson=require(_0x93f9('0x9'));var client=jayson[_0x93f9('0xa')][_0x93f9('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x2739e5,_0x24cf6a,_0x50517b){return new BPromise(function(_0x3355e1,_0xfbc98){return client[_0x93f9('0xc')](_0x2739e5,_0x50517b)[_0x93f9('0xd')](function(_0xbe8599){logger[_0x93f9('0xe')](_0x93f9('0xf'),_0x24cf6a,_0x93f9('0x10'));logger['debug'](_0x93f9('0x11'),_0x24cf6a,_0x93f9('0x10'),JSON[_0x93f9('0x12')](_0xbe8599));if(_0xbe8599[_0x93f9('0x13')]){if(_0xbe8599['error'][_0x93f9('0x14')]===0x1f4){logger[_0x93f9('0x13')](_0x93f9('0xf'),_0x24cf6a,_0xbe8599[_0x93f9('0x13')][_0x93f9('0x15')]);return _0xfbc98(_0xbe8599[_0x93f9('0x13')]['message']);}logger['error'](_0x93f9('0xf'),_0x24cf6a,_0xbe8599['error']['message']);return _0x3355e1(_0xbe8599[_0x93f9('0x13')][_0x93f9('0x15')]);}else{logger[_0x93f9('0xe')](_0x93f9('0xf'),_0x24cf6a,_0x93f9('0x10'));_0x3355e1(_0xbe8599[_0x93f9('0x16')][_0x93f9('0x15')]);}})[_0x93f9('0x17')](function(_0x4bbcb9){logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0x24cf6a,_0x4bbcb9);_0xfbc98(_0x4bbcb9);});});}exports[_0x93f9('0x18')]=function(_0x2a837b){var _0x2f83bf=this;return new Promise(function(_0x14a91d,_0x883132){return db['WhatsappQueueReport']['create'](_0x2a837b[_0x93f9('0x19')],{'raw':_0x2a837b[_0x93f9('0x1a')]?_0x2a837b[_0x93f9('0x1a')][_0x93f9('0x1b')]===undefined?!![]:![]:!![]})[_0x93f9('0xd')](function(_0x509834){logger[_0x93f9('0xe')]('CreateWhatsappQueueReport',_0x2a837b);logger['debug'](_0x93f9('0x18'),_0x2a837b,JSON[_0x93f9('0x12')](_0x509834));_0x14a91d(_0x509834);})['catch'](function(_0x224f95){logger[_0x93f9('0x13')](_0x93f9('0x18'),_0x224f95[_0x93f9('0x15')],_0x2a837b);_0x883132(_0x2f83bf[_0x93f9('0x13')](0x1f4,_0x224f95['message']));});});};exports[_0x93f9('0x1c')]=function(_0x328baf){var _0x40f0c3=this;return new Promise(function(_0x394efb,_0x4ef728){return db['WhatsappQueueReport'][_0x93f9('0x1d')](_0x328baf['body'],{'raw':_0x328baf[_0x93f9('0x1a')]?_0x328baf[_0x93f9('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x328baf[_0x93f9('0x1a')]?_0x328baf[_0x93f9('0x1a')][_0x93f9('0x1e')]||null:null,'attributes':_0x328baf[_0x93f9('0x1a')]?_0x328baf['options'][_0x93f9('0x1f')]||null:null,'limit':_0x328baf[_0x93f9('0x1a')]?_0x328baf[_0x93f9('0x1a')]['limit']||null:null})[_0x93f9('0xd')](function(_0x5b153f){logger[_0x93f9('0xe')](_0x93f9('0x1c'),_0x328baf);logger[_0x93f9('0x20')]('UpdateWhatsappQueueReport',_0x328baf,JSON[_0x93f9('0x12')](_0x5b153f));_0x394efb(_0x5b153f);})[_0x93f9('0x17')](function(_0x3d14f7){logger[_0x93f9('0x13')](_0x93f9('0x1c'),_0x3d14f7[_0x93f9('0x15')],_0x328baf);_0x4ef728(_0x40f0c3[_0x93f9('0x13')](0x1f4,_0x3d14f7[_0x93f9('0x15')]));});});};