Built motion from commit f0a64034.|2.6.11
[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 _0xda6d=['request\x20sent','debug','stringify','error','code','message','info','catch','WhatsappQueueReport','create','options','raw','CreateWhatsappQueueReport','UpdateWhatsappQueueReport','update','attributes','lodash','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','WhatsappQueueReport,\x20%s,\x20%s'];(function(_0x292423,_0x1759b7){var _0x2801cb=function(_0x23c821){while(--_0x23c821){_0x292423['push'](_0x292423['shift']());}};_0x2801cb(++_0x1759b7);}(_0xda6d,0x11e));var _0xdda6=function(_0x3b5cdd,_0x141da4){_0x3b5cdd=_0x3b5cdd-0x0;var _0x56008b=_0xda6d[_0x3b5cdd];return _0x56008b;};'use strict';var _=require(_0xdda6('0x0'));var util=require('util');var moment=require(_0xdda6('0x1'));var BPromise=require('bluebird');var rs=require(_0xdda6('0x2'));var fs=require('fs');var Redis=require(_0xdda6('0x3'));var db=require(_0xdda6('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xdda6('0x5'))(_0xdda6('0x6'));var config=require(_0xdda6('0x7'));var jayson=require(_0xdda6('0x8'));var client=jayson[_0xdda6('0x9')][_0xdda6('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4967eb,_0x1e8f80,_0x569af1){return new BPromise(function(_0x3a6ffb,_0x4abf43){return client[_0xdda6('0xb')](_0x4967eb,_0x569af1)[_0xdda6('0xc')](function(_0x326ce5){logger['info'](_0xdda6('0xd'),_0x1e8f80,_0xdda6('0xe'));logger[_0xdda6('0xf')]('WhatsappQueueReport,\x20%s,\x20%s,\x20%s',_0x1e8f80,_0xdda6('0xe'),JSON[_0xdda6('0x10')](_0x326ce5));if(_0x326ce5[_0xdda6('0x11')]){if(_0x326ce5[_0xdda6('0x11')][_0xdda6('0x12')]===0x1f4){logger[_0xdda6('0x11')](_0xdda6('0xd'),_0x1e8f80,_0x326ce5[_0xdda6('0x11')][_0xdda6('0x13')]);return _0x4abf43(_0x326ce5['error']['message']);}logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0x1e8f80,_0x326ce5['error']['message']);return _0x3a6ffb(_0x326ce5[_0xdda6('0x11')]['message']);}else{logger[_0xdda6('0x14')]('WhatsappQueueReport,\x20%s,\x20%s',_0x1e8f80,'request\x20sent');_0x3a6ffb(_0x326ce5['result'][_0xdda6('0x13')]);}})[_0xdda6('0x15')](function(_0x2a68d0){logger['error'](_0xdda6('0xd'),_0x1e8f80,_0x2a68d0);_0x4abf43(_0x2a68d0);});});}exports['CreateWhatsappQueueReport']=function(_0x515f7a){var _0x6305b7=this;return new Promise(function(_0x291a54,_0x3552bd){return db[_0xdda6('0x16')][_0xdda6('0x17')](_0x515f7a['body'],{'raw':_0x515f7a[_0xdda6('0x18')]?_0x515f7a[_0xdda6('0x18')][_0xdda6('0x19')]===undefined?!![]:![]:!![]})[_0xdda6('0xc')](function(_0x27435a){logger[_0xdda6('0x14')]('CreateWhatsappQueueReport',_0x515f7a);logger[_0xdda6('0xf')]('CreateWhatsappQueueReport',_0x515f7a,JSON[_0xdda6('0x10')](_0x27435a));_0x291a54(_0x27435a);})[_0xdda6('0x15')](function(_0x549625){logger['error'](_0xdda6('0x1a'),_0x549625[_0xdda6('0x13')],_0x515f7a);_0x3552bd(_0x6305b7[_0xdda6('0x11')](0x1f4,_0x549625[_0xdda6('0x13')]));});});};exports[_0xdda6('0x1b')]=function(_0x3cde98){var _0x450791=this;return new Promise(function(_0x253431,_0x1363c5){return db[_0xdda6('0x16')][_0xdda6('0x1c')](_0x3cde98['body'],{'raw':_0x3cde98['options']?_0x3cde98[_0xdda6('0x18')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3cde98[_0xdda6('0x18')]?_0x3cde98[_0xdda6('0x18')]['where']||null:null,'attributes':_0x3cde98[_0xdda6('0x18')]?_0x3cde98['options'][_0xdda6('0x1d')]||null:null,'limit':_0x3cde98[_0xdda6('0x18')]?_0x3cde98[_0xdda6('0x18')]['limit']||null:null})[_0xdda6('0xc')](function(_0x5af977){logger[_0xdda6('0x14')]('UpdateWhatsappQueueReport',_0x3cde98);logger['debug'](_0xdda6('0x1b'),_0x3cde98,JSON['stringify'](_0x5af977));_0x253431(_0x5af977);})['catch'](function(_0x29d8cb){logger['error']('UpdateWhatsappQueueReport',_0x29d8cb[_0xdda6('0x13')],_0x3cde98);_0x1363c5(_0x450791['error'](0x1f4,_0x29d8cb['message']));});});};