e904618f5cc0176d13cd031e0b0651462d495c09
[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 _0x4175=['error','code','message','result','catch','CreateWhatsappQueueReport','WhatsappQueueReport','create','body','options','raw','then','UpdateWhatsappQueueReport','where','attributes','limit','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','request','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x1d25e4,_0x455583){var _0x3f1238=function(_0xd5d35){while(--_0xd5d35){_0x1d25e4['push'](_0x1d25e4['shift']());}};_0x3f1238(++_0x455583);}(_0x4175,0x164));var _0x5417=function(_0x50537,_0x3ea336){_0x50537=_0x50537-0x0;var _0x5703e9=_0x4175[_0x50537];return _0x5703e9;};'use strict';var _=require(_0x5417('0x0'));var util=require(_0x5417('0x1'));var moment=require(_0x5417('0x2'));var BPromise=require(_0x5417('0x3'));var rs=require(_0x5417('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5417('0x5'))['db'];var utils=require(_0x5417('0x6'));var logger=require('../../config/logger')(_0x5417('0x7'));var config=require(_0x5417('0x8'));var jayson=require(_0x5417('0x9'));var client=jayson[_0x5417('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1e77a8,_0x4b0329,_0x552390){return new BPromise(function(_0x5e38ec,_0x5dd864){return client[_0x5417('0xb')](_0x1e77a8,_0x552390)['then'](function(_0x4a07ca){logger[_0x5417('0xc')](_0x5417('0xd'),_0x4b0329,_0x5417('0xe'));logger[_0x5417('0xf')](_0x5417('0x10'),_0x4b0329,'request\x20sent',JSON[_0x5417('0x11')](_0x4a07ca));if(_0x4a07ca['error']){if(_0x4a07ca[_0x5417('0x12')][_0x5417('0x13')]===0x1f4){logger[_0x5417('0x12')]('WhatsappQueueReport,\x20%s,\x20%s',_0x4b0329,_0x4a07ca['error'][_0x5417('0x14')]);return _0x5dd864(_0x4a07ca[_0x5417('0x12')][_0x5417('0x14')]);}logger[_0x5417('0x12')]('WhatsappQueueReport,\x20%s,\x20%s',_0x4b0329,_0x4a07ca[_0x5417('0x12')][_0x5417('0x14')]);return _0x5e38ec(_0x4a07ca['error']['message']);}else{logger[_0x5417('0xc')](_0x5417('0xd'),_0x4b0329,_0x5417('0xe'));_0x5e38ec(_0x4a07ca[_0x5417('0x15')][_0x5417('0x14')]);}})[_0x5417('0x16')](function(_0x29b575){logger[_0x5417('0x12')](_0x5417('0xd'),_0x4b0329,_0x29b575);_0x5dd864(_0x29b575);});});}exports[_0x5417('0x17')]=function(_0xcc592e){var _0x219149=this;return new Promise(function(_0x4c2f5d,_0x46ba25){return db[_0x5417('0x18')][_0x5417('0x19')](_0xcc592e[_0x5417('0x1a')],{'raw':_0xcc592e[_0x5417('0x1b')]?_0xcc592e[_0x5417('0x1b')][_0x5417('0x1c')]===undefined?!![]:![]:!![]})[_0x5417('0x1d')](function(_0x35eabf){logger[_0x5417('0xc')](_0x5417('0x17'),_0xcc592e);logger[_0x5417('0xf')](_0x5417('0x17'),_0xcc592e,JSON[_0x5417('0x11')](_0x35eabf));_0x4c2f5d(_0x35eabf);})['catch'](function(_0x35409d){logger[_0x5417('0x12')]('CreateWhatsappQueueReport',_0x35409d[_0x5417('0x14')],_0xcc592e);_0x46ba25(_0x219149['error'](0x1f4,_0x35409d['message']));});});};exports[_0x5417('0x1e')]=function(_0x50727c){var _0x516cad=this;return new Promise(function(_0x460bbc,_0x39dc7b){return db[_0x5417('0x18')]['update'](_0x50727c['body'],{'raw':_0x50727c[_0x5417('0x1b')]?_0x50727c[_0x5417('0x1b')][_0x5417('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x50727c['options']?_0x50727c[_0x5417('0x1b')][_0x5417('0x1f')]||null:null,'attributes':_0x50727c['options']?_0x50727c[_0x5417('0x1b')][_0x5417('0x20')]||null:null,'limit':_0x50727c['options']?_0x50727c[_0x5417('0x1b')][_0x5417('0x21')]||null:null})[_0x5417('0x1d')](function(_0x442299){logger[_0x5417('0xc')]('UpdateWhatsappQueueReport',_0x50727c);logger['debug'](_0x5417('0x1e'),_0x50727c,JSON['stringify'](_0x442299));_0x460bbc(_0x442299);})['catch'](function(_0x45677f){logger[_0x5417('0x12')](_0x5417('0x1e'),_0x45677f[_0x5417('0x14')],_0x50727c);_0x39dc7b(_0x516cad[_0x5417('0x12')](0x1f4,_0x45677f['message']));});});};