90fdfc9880469510907b40cfd11bfe15ba7f5404
[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 _0x5848=['then','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','error','code','WhatsappQueueReport,\x20%s,\x20%s','message','result','catch','WhatsappQueueReport','body','options','raw','info','stringify','CreateWhatsappQueueReport','update','where','limit','UpdateWhatsappQueueReport','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http'];(function(_0x2c91e9,_0x2fb965){var _0x13f0ff=function(_0xb39edf){while(--_0xb39edf){_0x2c91e9['push'](_0x2c91e9['shift']());}};_0x13f0ff(++_0x2fb965);}(_0x5848,0x10d));var _0x8584=function(_0x2ac8b1,_0x27770d){_0x2ac8b1=_0x2ac8b1-0x0;var _0x3370de=_0x5848[_0x2ac8b1];return _0x3370de;};'use strict';var _=require(_0x8584('0x0'));var util=require(_0x8584('0x1'));var moment=require(_0x8584('0x2'));var BPromise=require('bluebird');var rs=require(_0x8584('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x8584('0x4'))['db'];var utils=require(_0x8584('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0x8584('0x6'));var jayson=require(_0x8584('0x7'));var client=jayson[_0x8584('0x8')][_0x8584('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x51b95c,_0x3dc861,_0x5ab0aa){return new BPromise(function(_0x53cddc,_0x35b09f){return client['request'](_0x51b95c,_0x5ab0aa)[_0x8584('0xa')](function(_0x57c921){logger['info']('WhatsappQueueReport,\x20%s,\x20%s',_0x3dc861,_0x8584('0xb'));logger[_0x8584('0xc')](_0x8584('0xd'),_0x3dc861,'request\x20sent',JSON['stringify'](_0x57c921));if(_0x57c921[_0x8584('0xe')]){if(_0x57c921[_0x8584('0xe')][_0x8584('0xf')]===0x1f4){logger['error'](_0x8584('0x10'),_0x3dc861,_0x57c921[_0x8584('0xe')][_0x8584('0x11')]);return _0x35b09f(_0x57c921[_0x8584('0xe')][_0x8584('0x11')]);}logger[_0x8584('0xe')](_0x8584('0x10'),_0x3dc861,_0x57c921[_0x8584('0xe')][_0x8584('0x11')]);return _0x53cddc(_0x57c921['error'][_0x8584('0x11')]);}else{logger['info'](_0x8584('0x10'),_0x3dc861,_0x8584('0xb'));_0x53cddc(_0x57c921[_0x8584('0x12')]['message']);}})[_0x8584('0x13')](function(_0x21a61a){logger[_0x8584('0xe')](_0x8584('0x10'),_0x3dc861,_0x21a61a);_0x35b09f(_0x21a61a);});});}exports['CreateWhatsappQueueReport']=function(_0x521cf1){var _0x211ea4=this;return new Promise(function(_0x1faaa6,_0x5b72c0){return db[_0x8584('0x14')]['create'](_0x521cf1[_0x8584('0x15')],{'raw':_0x521cf1[_0x8584('0x16')]?_0x521cf1['options'][_0x8584('0x17')]===undefined?!![]:![]:!![]})[_0x8584('0xa')](function(_0x291dfa){logger[_0x8584('0x18')]('CreateWhatsappQueueReport',_0x521cf1);logger[_0x8584('0xc')]('CreateWhatsappQueueReport',_0x521cf1,JSON[_0x8584('0x19')](_0x291dfa));_0x1faaa6(_0x291dfa);})['catch'](function(_0x419364){logger[_0x8584('0xe')](_0x8584('0x1a'),_0x419364[_0x8584('0x11')],_0x521cf1);_0x5b72c0(_0x211ea4['error'](0x1f4,_0x419364['message']));});});};exports['UpdateWhatsappQueueReport']=function(_0x18e9c2){var _0x2340fd=this;return new Promise(function(_0x758b3c,_0x1c4346){return db[_0x8584('0x14')][_0x8584('0x1b')](_0x18e9c2[_0x8584('0x15')],{'raw':_0x18e9c2['options']?_0x18e9c2['options'][_0x8584('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x18e9c2[_0x8584('0x16')]?_0x18e9c2[_0x8584('0x16')][_0x8584('0x1c')]||null:null,'attributes':_0x18e9c2[_0x8584('0x16')]?_0x18e9c2[_0x8584('0x16')]['attributes']||null:null,'limit':_0x18e9c2[_0x8584('0x16')]?_0x18e9c2[_0x8584('0x16')][_0x8584('0x1d')]||null:null})[_0x8584('0xa')](function(_0x2b8ea9){logger[_0x8584('0x18')](_0x8584('0x1e'),_0x18e9c2);logger[_0x8584('0xc')](_0x8584('0x1e'),_0x18e9c2,JSON['stringify'](_0x2b8ea9));_0x758b3c(_0x2b8ea9);})[_0x8584('0x13')](function(_0x2b2aa0){logger[_0x8584('0xe')]('UpdateWhatsappQueueReport',_0x2b2aa0[_0x8584('0x11')],_0x18e9c2);_0x1c4346(_0x2340fd[_0x8584('0xe')](0x1f4,_0x2b2aa0[_0x8584('0x11')]));});});};