1532b7993faff33e9059a51a152fd7174ae58ac7
[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 _0x9087=['ioredis','../../config/utils','../../config/logger','jayson/promise','client','http','request','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','message','result','CreateWhatsappQueueReport','WhatsappQueueReport','create','body','options','raw','then','UpdateWhatsappQueueReport','update','attributes','limit','catch','lodash','util','moment','bluebird','randomstring'];(function(_0x567b01,_0xe370f){var _0x3225bf=function(_0x4cacb8){while(--_0x4cacb8){_0x567b01['push'](_0x567b01['shift']());}};_0x3225bf(++_0xe370f);}(_0x9087,0x1ea));var _0x7908=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x9087[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x7908('0x0'));var util=require(_0x7908('0x1'));var moment=require(_0x7908('0x2'));var BPromise=require(_0x7908('0x3'));var rs=require(_0x7908('0x4'));var fs=require('fs');var Redis=require(_0x7908('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x7908('0x6'));var logger=require(_0x7908('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x7908('0x8'));var client=jayson[_0x7908('0x9')][_0x7908('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x37f770,_0x553986,_0x1ea20a){return new BPromise(function(_0xe217ff,_0x3a4f2c){return client[_0x7908('0xb')](_0x37f770,_0x1ea20a)['then'](function(_0xf743f9){logger[_0x7908('0xc')](_0x7908('0xd'),_0x553986,_0x7908('0xe'));logger[_0x7908('0xf')](_0x7908('0x10'),_0x553986,_0x7908('0xe'),JSON[_0x7908('0x11')](_0xf743f9));if(_0xf743f9[_0x7908('0x12')]){if(_0xf743f9[_0x7908('0x12')]['code']===0x1f4){logger[_0x7908('0x12')](_0x7908('0xd'),_0x553986,_0xf743f9['error'][_0x7908('0x13')]);return _0x3a4f2c(_0xf743f9['error'][_0x7908('0x13')]);}logger['error'](_0x7908('0xd'),_0x553986,_0xf743f9['error'][_0x7908('0x13')]);return _0xe217ff(_0xf743f9[_0x7908('0x12')][_0x7908('0x13')]);}else{logger[_0x7908('0xc')](_0x7908('0xd'),_0x553986,_0x7908('0xe'));_0xe217ff(_0xf743f9[_0x7908('0x14')]['message']);}})['catch'](function(_0x1e64c4){logger[_0x7908('0x12')](_0x7908('0xd'),_0x553986,_0x1e64c4);_0x3a4f2c(_0x1e64c4);});});}exports[_0x7908('0x15')]=function(_0x32e6a3){var _0x5640ef=this;return new Promise(function(_0x7cee13,_0x1371a1){return db[_0x7908('0x16')][_0x7908('0x17')](_0x32e6a3[_0x7908('0x18')],{'raw':_0x32e6a3[_0x7908('0x19')]?_0x32e6a3['options'][_0x7908('0x1a')]===undefined?!![]:![]:!![]})[_0x7908('0x1b')](function(_0x2c6336){logger[_0x7908('0xc')](_0x7908('0x15'),_0x32e6a3);logger[_0x7908('0xf')]('CreateWhatsappQueueReport',_0x32e6a3,JSON[_0x7908('0x11')](_0x2c6336));_0x7cee13(_0x2c6336);})['catch'](function(_0x504a23){logger['error'](_0x7908('0x15'),_0x504a23[_0x7908('0x13')],_0x32e6a3);_0x1371a1(_0x5640ef[_0x7908('0x12')](0x1f4,_0x504a23[_0x7908('0x13')]));});});};exports[_0x7908('0x1c')]=function(_0x4244f2){var _0x56be0a=this;return new Promise(function(_0x254cd8,_0x5b878b){return db[_0x7908('0x16')][_0x7908('0x1d')](_0x4244f2['body'],{'raw':_0x4244f2[_0x7908('0x19')]?_0x4244f2['options'][_0x7908('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4244f2[_0x7908('0x19')]?_0x4244f2[_0x7908('0x19')]['where']||null:null,'attributes':_0x4244f2['options']?_0x4244f2[_0x7908('0x19')][_0x7908('0x1e')]||null:null,'limit':_0x4244f2['options']?_0x4244f2[_0x7908('0x19')][_0x7908('0x1f')]||null:null})[_0x7908('0x1b')](function(_0x342014){logger['info']('UpdateWhatsappQueueReport',_0x4244f2);logger['debug'](_0x7908('0x1c'),_0x4244f2,JSON[_0x7908('0x11')](_0x342014));_0x254cd8(_0x342014);})[_0x7908('0x20')](function(_0x381cef){logger['error']('UpdateWhatsappQueueReport',_0x381cef[_0x7908('0x13')],_0x4244f2);_0x5b878b(_0x56be0a['error'](0x1f4,_0x381cef[_0x7908('0x13')]));});});};