8b80abe56e5898d3110e58a8bb8ddd83eedab383
[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 _0x4173=['options','raw','CreateWhatsappQueueReport','UpdateWhatsappQueueReport','update','body','where','attributes','limit','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','http','then','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','WhatsappQueueReport','create'];(function(_0x529870,_0x975245){var _0x39435f=function(_0x408986){while(--_0x408986){_0x529870['push'](_0x529870['shift']());}};_0x39435f(++_0x975245);}(_0x4173,0x101));var _0x3417=function(_0x5c7221,_0x2867ff){_0x5c7221=_0x5c7221-0x0;var _0x34ff4a=_0x4173[_0x5c7221];return _0x34ff4a;};'use strict';var _=require(_0x3417('0x0'));var util=require(_0x3417('0x1'));var moment=require(_0x3417('0x2'));var BPromise=require(_0x3417('0x3'));var rs=require(_0x3417('0x4'));var fs=require('fs');var Redis=require(_0x3417('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x3417('0x6'));var logger=require(_0x3417('0x7'))(_0x3417('0x8'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0x3417('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4b3bde,_0x297170,_0x1039c9){return new BPromise(function(_0x4997b6,_0x294e3e){return client['request'](_0x4b3bde,_0x1039c9)[_0x3417('0xa')](function(_0x2b1ebf){logger[_0x3417('0xb')](_0x3417('0xc'),_0x297170,_0x3417('0xd'));logger[_0x3417('0xe')](_0x3417('0xf'),_0x297170,'request\x20sent',JSON[_0x3417('0x10')](_0x2b1ebf));if(_0x2b1ebf[_0x3417('0x11')]){if(_0x2b1ebf['error']['code']===0x1f4){logger['error'](_0x3417('0xc'),_0x297170,_0x2b1ebf['error'][_0x3417('0x12')]);return _0x294e3e(_0x2b1ebf[_0x3417('0x11')][_0x3417('0x12')]);}logger[_0x3417('0x11')](_0x3417('0xc'),_0x297170,_0x2b1ebf['error']['message']);return _0x4997b6(_0x2b1ebf['error'][_0x3417('0x12')]);}else{logger['info']('WhatsappQueueReport,\x20%s,\x20%s',_0x297170,'request\x20sent');_0x4997b6(_0x2b1ebf['result']['message']);}})[_0x3417('0x13')](function(_0x408fdd){logger[_0x3417('0x11')](_0x3417('0xc'),_0x297170,_0x408fdd);_0x294e3e(_0x408fdd);});});}exports['CreateWhatsappQueueReport']=function(_0x2de3b5){var _0x1e3204=this;return new Promise(function(_0x43191d,_0x43d8b7){return db[_0x3417('0x14')][_0x3417('0x15')](_0x2de3b5['body'],{'raw':_0x2de3b5[_0x3417('0x16')]?_0x2de3b5[_0x3417('0x16')][_0x3417('0x17')]===undefined?!![]:![]:!![]})[_0x3417('0xa')](function(_0x20c9af){logger[_0x3417('0xb')](_0x3417('0x18'),_0x2de3b5);logger[_0x3417('0xe')](_0x3417('0x18'),_0x2de3b5,JSON[_0x3417('0x10')](_0x20c9af));_0x43191d(_0x20c9af);})[_0x3417('0x13')](function(_0x2c2ff0){logger[_0x3417('0x11')]('CreateWhatsappQueueReport',_0x2c2ff0[_0x3417('0x12')],_0x2de3b5);_0x43d8b7(_0x1e3204[_0x3417('0x11')](0x1f4,_0x2c2ff0[_0x3417('0x12')]));});});};exports[_0x3417('0x19')]=function(_0x1920b9){var _0x2cf6eb=this;return new Promise(function(_0x315320,_0x3b2902){return db[_0x3417('0x14')][_0x3417('0x1a')](_0x1920b9[_0x3417('0x1b')],{'raw':_0x1920b9[_0x3417('0x16')]?_0x1920b9[_0x3417('0x16')][_0x3417('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1920b9[_0x3417('0x16')]?_0x1920b9[_0x3417('0x16')][_0x3417('0x1c')]||null:null,'attributes':_0x1920b9[_0x3417('0x16')]?_0x1920b9['options'][_0x3417('0x1d')]||null:null,'limit':_0x1920b9[_0x3417('0x16')]?_0x1920b9[_0x3417('0x16')][_0x3417('0x1e')]||null:null})[_0x3417('0xa')](function(_0x30aecb){logger[_0x3417('0xb')](_0x3417('0x19'),_0x1920b9);logger[_0x3417('0xe')]('UpdateWhatsappQueueReport',_0x1920b9,JSON[_0x3417('0x10')](_0x30aecb));_0x315320(_0x30aecb);})[_0x3417('0x13')](function(_0x1ab2cf){logger[_0x3417('0x11')](_0x3417('0x19'),_0x1ab2cf[_0x3417('0x12')],_0x1920b9);_0x3b2902(_0x2cf6eb[_0x3417('0x11')](0x1f4,_0x1ab2cf['message']));});});};