0c1a6d7f929456bdaa3f00fdb35bc6ebfa04966d
[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 _0x44d3=['../../config/logger','../../config/environment','jayson/promise','client','http','request','then','WhatsappQueueReport,\x20%s,\x20%s','debug','request\x20sent','stringify','error','message','info','catch','WhatsappQueueReport','body','options','raw','CreateWhatsappQueueReport','UpdateWhatsappQueueReport','update','attributes','limit','lodash','util','moment','randomstring','ioredis','../../config/utils'];(function(_0x49a0bf,_0xe8c905){var _0x30bc35=function(_0x46cfe3){while(--_0x46cfe3){_0x49a0bf['push'](_0x49a0bf['shift']());}};_0x30bc35(++_0xe8c905);}(_0x44d3,0x1bc));var _0x344d=function(_0x4c04be,_0x2e3e1a){_0x4c04be=_0x4c04be-0x0;var _0x8263f9=_0x44d3[_0x4c04be];return _0x8263f9;};'use strict';var _=require(_0x344d('0x0'));var util=require(_0x344d('0x1'));var moment=require(_0x344d('0x2'));var BPromise=require('bluebird');var rs=require(_0x344d('0x3'));var fs=require('fs');var Redis=require(_0x344d('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x344d('0x5'));var logger=require(_0x344d('0x6'))('rpc');var config=require(_0x344d('0x7'));var jayson=require(_0x344d('0x8'));var client=jayson[_0x344d('0x9')][_0x344d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3da360,_0x3bd374,_0x124c23){return new BPromise(function(_0x286789,_0x2a2c05){return client[_0x344d('0xb')](_0x3da360,_0x124c23)[_0x344d('0xc')](function(_0x2e2491){logger['info'](_0x344d('0xd'),_0x3bd374,'request\x20sent');logger[_0x344d('0xe')]('WhatsappQueueReport,\x20%s,\x20%s,\x20%s',_0x3bd374,_0x344d('0xf'),JSON[_0x344d('0x10')](_0x2e2491));if(_0x2e2491[_0x344d('0x11')]){if(_0x2e2491[_0x344d('0x11')]['code']===0x1f4){logger[_0x344d('0x11')]('WhatsappQueueReport,\x20%s,\x20%s',_0x3bd374,_0x2e2491[_0x344d('0x11')][_0x344d('0x12')]);return _0x2a2c05(_0x2e2491[_0x344d('0x11')]['message']);}logger[_0x344d('0x11')](_0x344d('0xd'),_0x3bd374,_0x2e2491['error'][_0x344d('0x12')]);return _0x286789(_0x2e2491['error'][_0x344d('0x12')]);}else{logger[_0x344d('0x13')]('WhatsappQueueReport,\x20%s,\x20%s',_0x3bd374,_0x344d('0xf'));_0x286789(_0x2e2491['result']['message']);}})[_0x344d('0x14')](function(_0xe4de0b){logger[_0x344d('0x11')](_0x344d('0xd'),_0x3bd374,_0xe4de0b);_0x2a2c05(_0xe4de0b);});});}exports['CreateWhatsappQueueReport']=function(_0x542d5b){var _0x4364a6=this;return new Promise(function(_0x486170,_0x1dbbe1){return db[_0x344d('0x15')]['create'](_0x542d5b[_0x344d('0x16')],{'raw':_0x542d5b[_0x344d('0x17')]?_0x542d5b[_0x344d('0x17')][_0x344d('0x18')]===undefined?!![]:![]:!![]})[_0x344d('0xc')](function(_0x1e20ef){logger[_0x344d('0x13')]('CreateWhatsappQueueReport',_0x542d5b);logger[_0x344d('0xe')](_0x344d('0x19'),_0x542d5b,JSON[_0x344d('0x10')](_0x1e20ef));_0x486170(_0x1e20ef);})[_0x344d('0x14')](function(_0x20f2dd){logger['error'](_0x344d('0x19'),_0x20f2dd[_0x344d('0x12')],_0x542d5b);_0x1dbbe1(_0x4364a6[_0x344d('0x11')](0x1f4,_0x20f2dd[_0x344d('0x12')]));});});};exports[_0x344d('0x1a')]=function(_0x2551a3){var _0x1e00e6=this;return new Promise(function(_0xb0e829,_0x11a652){return db[_0x344d('0x15')][_0x344d('0x1b')](_0x2551a3[_0x344d('0x16')],{'raw':_0x2551a3[_0x344d('0x17')]?_0x2551a3[_0x344d('0x17')][_0x344d('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2551a3[_0x344d('0x17')]?_0x2551a3[_0x344d('0x17')]['where']||null:null,'attributes':_0x2551a3[_0x344d('0x17')]?_0x2551a3[_0x344d('0x17')][_0x344d('0x1c')]||null:null,'limit':_0x2551a3[_0x344d('0x17')]?_0x2551a3[_0x344d('0x17')][_0x344d('0x1d')]||null:null})[_0x344d('0xc')](function(_0x4320b7){logger[_0x344d('0x13')](_0x344d('0x1a'),_0x2551a3);logger['debug'](_0x344d('0x1a'),_0x2551a3,JSON[_0x344d('0x10')](_0x4320b7));_0xb0e829(_0x4320b7);})['catch'](function(_0x4f0fc9){logger[_0x344d('0x11')](_0x344d('0x1a'),_0x4f0fc9[_0x344d('0x12')],_0x2551a3);_0x11a652(_0x1e00e6[_0x344d('0x11')](0x1f4,_0x4f0fc9[_0x344d('0x12')]));});});};