1ea5825e81dad884476f4b1612453473aa2ac778
[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 _0x69c1=['body','options','CreateWhatsappQueueReport','UpdateWhatsappQueueReport','WhatsappQueueReport','update','raw','where','limit','util','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','client','request','then','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch'];(function(_0x467c7c,_0x17bd60){var _0x13d8e1=function(_0x4d10c9){while(--_0x4d10c9){_0x467c7c['push'](_0x467c7c['shift']());}};_0x13d8e1(++_0x17bd60);}(_0x69c1,0xf1));var _0x169c=function(_0xdf3db6,_0x2a1952){_0xdf3db6=_0xdf3db6-0x0;var _0x4b7a65=_0x69c1[_0xdf3db6];return _0x4b7a65;};'use strict';var _=require('lodash');var util=require(_0x169c('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x169c('0x1'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x169c('0x2'));var logger=require(_0x169c('0x3'))(_0x169c('0x4'));var config=require(_0x169c('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x169c('0x6')]['http']({'port':0x232a});function respondWithRpcPromise(_0xf38032,_0x4a8b4d,_0x3fd4b3){return new BPromise(function(_0x398f8a,_0x7931af){return client[_0x169c('0x7')](_0xf38032,_0x3fd4b3)[_0x169c('0x8')](function(_0x25f1a5){logger[_0x169c('0x9')](_0x169c('0xa'),_0x4a8b4d,_0x169c('0xb'));logger[_0x169c('0xc')](_0x169c('0xd'),_0x4a8b4d,_0x169c('0xb'),JSON[_0x169c('0xe')](_0x25f1a5));if(_0x25f1a5[_0x169c('0xf')]){if(_0x25f1a5[_0x169c('0xf')][_0x169c('0x10')]===0x1f4){logger[_0x169c('0xf')](_0x169c('0xa'),_0x4a8b4d,_0x25f1a5[_0x169c('0xf')][_0x169c('0x11')]);return _0x7931af(_0x25f1a5[_0x169c('0xf')][_0x169c('0x11')]);}logger[_0x169c('0xf')](_0x169c('0xa'),_0x4a8b4d,_0x25f1a5['error'][_0x169c('0x11')]);return _0x398f8a(_0x25f1a5[_0x169c('0xf')][_0x169c('0x11')]);}else{logger['info'](_0x169c('0xa'),_0x4a8b4d,_0x169c('0xb'));_0x398f8a(_0x25f1a5[_0x169c('0x12')][_0x169c('0x11')]);}})[_0x169c('0x13')](function(_0x2280b3){logger[_0x169c('0xf')](_0x169c('0xa'),_0x4a8b4d,_0x2280b3);_0x7931af(_0x2280b3);});});}exports['CreateWhatsappQueueReport']=function(_0x5a29f9){var _0x2a9258=this;return new Promise(function(_0x46dd7f,_0xc77bd5){return db['WhatsappQueueReport']['create'](_0x5a29f9[_0x169c('0x14')],{'raw':_0x5a29f9['options']?_0x5a29f9[_0x169c('0x15')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x291032){logger['info'](_0x169c('0x16'),_0x5a29f9);logger[_0x169c('0xc')](_0x169c('0x16'),_0x5a29f9,JSON['stringify'](_0x291032));_0x46dd7f(_0x291032);})[_0x169c('0x13')](function(_0x4ed19d){logger[_0x169c('0xf')](_0x169c('0x16'),_0x4ed19d[_0x169c('0x11')],_0x5a29f9);_0xc77bd5(_0x2a9258[_0x169c('0xf')](0x1f4,_0x4ed19d[_0x169c('0x11')]));});});};exports[_0x169c('0x17')]=function(_0x3f661b){var _0x5a4623=this;return new Promise(function(_0x83b6de,_0x4dcd4b){return db[_0x169c('0x18')][_0x169c('0x19')](_0x3f661b['body'],{'raw':_0x3f661b[_0x169c('0x15')]?_0x3f661b[_0x169c('0x15')][_0x169c('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3f661b[_0x169c('0x15')]?_0x3f661b[_0x169c('0x15')][_0x169c('0x1b')]||null:null,'attributes':_0x3f661b[_0x169c('0x15')]?_0x3f661b[_0x169c('0x15')]['attributes']||null:null,'limit':_0x3f661b[_0x169c('0x15')]?_0x3f661b['options'][_0x169c('0x1c')]||null:null})[_0x169c('0x8')](function(_0x37d8d2){logger[_0x169c('0x9')](_0x169c('0x17'),_0x3f661b);logger['debug'](_0x169c('0x17'),_0x3f661b,JSON[_0x169c('0xe')](_0x37d8d2));_0x83b6de(_0x37d8d2);})[_0x169c('0x13')](function(_0x113de8){logger['error'](_0x169c('0x17'),_0x113de8[_0x169c('0x11')],_0x3f661b);_0x4dcd4b(_0x5a4623[_0x169c('0xf')](0x1f4,_0x113de8[_0x169c('0x11')]));});});};