9cc9e7c5d2b7e09029f12f085bb71a3638f8731f
[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 _0x205b=['WhatsappQueueReport,\x20%s,\x20%s','message','info','request\x20sent','result','CreateWhatsappQueueReport','WhatsappQueueReport','create','body','options','stringify','catch','UpdateWhatsappQueueReport','update','where','attributes','limit','debug','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','rpc','jayson/promise','client','http','request','then','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','error','code'];(function(_0x277c33,_0x29f88b){var _0x355916=function(_0xf66d8f){while(--_0xf66d8f){_0x277c33['push'](_0x277c33['shift']());}};_0x355916(++_0x29f88b);}(_0x205b,0xd8));var _0xb205=function(_0x3e8c07,_0x2e27b6){_0x3e8c07=_0x3e8c07-0x0;var _0x14d3e5=_0x205b[_0x3e8c07];return _0x14d3e5;};'use strict';var _=require(_0xb205('0x0'));var util=require(_0xb205('0x1'));var moment=require(_0xb205('0x2'));var BPromise=require(_0xb205('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb205('0x4'))['db'];var utils=require(_0xb205('0x5'));var logger=require('../../config/logger')(_0xb205('0x6'));var config=require('../../config/environment');var jayson=require(_0xb205('0x7'));var client=jayson[_0xb205('0x8')][_0xb205('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3c7ced,_0x1ca5a2,_0x364efa){return new BPromise(function(_0x2b9112,_0x1c1dd8){return client[_0xb205('0xa')](_0x3c7ced,_0x364efa)[_0xb205('0xb')](function(_0x106053){logger['info']('WhatsappQueueReport,\x20%s,\x20%s',_0x1ca5a2,'request\x20sent');logger['debug'](_0xb205('0xc'),_0x1ca5a2,'request\x20sent',JSON['stringify'](_0x106053));if(_0x106053[_0xb205('0xd')]){if(_0x106053[_0xb205('0xd')][_0xb205('0xe')]===0x1f4){logger[_0xb205('0xd')](_0xb205('0xf'),_0x1ca5a2,_0x106053['error']['message']);return _0x1c1dd8(_0x106053[_0xb205('0xd')][_0xb205('0x10')]);}logger[_0xb205('0xd')](_0xb205('0xf'),_0x1ca5a2,_0x106053[_0xb205('0xd')][_0xb205('0x10')]);return _0x2b9112(_0x106053[_0xb205('0xd')][_0xb205('0x10')]);}else{logger[_0xb205('0x11')](_0xb205('0xf'),_0x1ca5a2,_0xb205('0x12'));_0x2b9112(_0x106053[_0xb205('0x13')]['message']);}})['catch'](function(_0xb321e7){logger[_0xb205('0xd')]('WhatsappQueueReport,\x20%s,\x20%s',_0x1ca5a2,_0xb321e7);_0x1c1dd8(_0xb321e7);});});}exports[_0xb205('0x14')]=function(_0x423145){var _0xc8df85=this;return new Promise(function(_0x2951a6,_0x14ba45){return db[_0xb205('0x15')][_0xb205('0x16')](_0x423145[_0xb205('0x17')],{'raw':_0x423145[_0xb205('0x18')]?_0x423145[_0xb205('0x18')]['raw']===undefined?!![]:![]:!![]})[_0xb205('0xb')](function(_0x43c039){logger['info'](_0xb205('0x14'),_0x423145);logger['debug'](_0xb205('0x14'),_0x423145,JSON[_0xb205('0x19')](_0x43c039));_0x2951a6(_0x43c039);})[_0xb205('0x1a')](function(_0x2a7764){logger[_0xb205('0xd')](_0xb205('0x14'),_0x2a7764['message'],_0x423145);_0x14ba45(_0xc8df85[_0xb205('0xd')](0x1f4,_0x2a7764['message']));});});};exports[_0xb205('0x1b')]=function(_0x10c275){var _0x696894=this;return new Promise(function(_0x477d88,_0x546289){return db[_0xb205('0x15')][_0xb205('0x1c')](_0x10c275[_0xb205('0x17')],{'raw':_0x10c275[_0xb205('0x18')]?_0x10c275['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x10c275[_0xb205('0x18')]?_0x10c275[_0xb205('0x18')][_0xb205('0x1d')]||null:null,'attributes':_0x10c275['options']?_0x10c275[_0xb205('0x18')][_0xb205('0x1e')]||null:null,'limit':_0x10c275['options']?_0x10c275['options'][_0xb205('0x1f')]||null:null})[_0xb205('0xb')](function(_0x2e8119){logger['info'](_0xb205('0x1b'),_0x10c275);logger[_0xb205('0x20')](_0xb205('0x1b'),_0x10c275,JSON[_0xb205('0x19')](_0x2e8119));_0x477d88(_0x2e8119);})['catch'](function(_0x3d7e2c){logger[_0xb205('0xd')](_0xb205('0x1b'),_0x3d7e2c['message'],_0x10c275);_0x546289(_0x696894[_0xb205('0xd')](0x1f4,_0x3d7e2c['message']));});});};