bae4def33d849f96cd1e86ddad9610e3682e1039
[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 _0x3a9e=['where','limit','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappQueueReport,\x20%s,\x20%s','message','info','result','catch','body','CreateWhatsappQueueReport','UpdateWhatsappQueueReport','update','options','raw'];(function(_0x1dbf16,_0x9f799d){var _0x34307d=function(_0xcc8495){while(--_0xcc8495){_0x1dbf16['push'](_0x1dbf16['shift']());}};_0x34307d(++_0x9f799d);}(_0x3a9e,0x162));var _0xe3a9=function(_0x153844,_0x37a9b9){_0x153844=_0x153844-0x0;var _0x4207d0=_0x3a9e[_0x153844];return _0x4207d0;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xe3a9('0x0'));var BPromise=require(_0xe3a9('0x1'));var rs=require(_0xe3a9('0x2'));var fs=require('fs');var Redis=require(_0xe3a9('0x3'));var db=require(_0xe3a9('0x4'))['db'];var utils=require(_0xe3a9('0x5'));var logger=require(_0xe3a9('0x6'))(_0xe3a9('0x7'));var config=require('../../config/environment');var jayson=require(_0xe3a9('0x8'));var client=jayson[_0xe3a9('0x9')][_0xe3a9('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2bb118,_0xe40436,_0x22c9ae){return new BPromise(function(_0x31ad40,_0x2e48ac){return client[_0xe3a9('0xb')](_0x2bb118,_0x22c9ae)[_0xe3a9('0xc')](function(_0x1fef77){logger['info']('WhatsappQueueReport,\x20%s,\x20%s',_0xe40436,_0xe3a9('0xd'));logger[_0xe3a9('0xe')](_0xe3a9('0xf'),_0xe40436,_0xe3a9('0xd'),JSON[_0xe3a9('0x10')](_0x1fef77));if(_0x1fef77['error']){if(_0x1fef77[_0xe3a9('0x11')][_0xe3a9('0x12')]===0x1f4){logger[_0xe3a9('0x11')](_0xe3a9('0x13'),_0xe40436,_0x1fef77['error'][_0xe3a9('0x14')]);return _0x2e48ac(_0x1fef77[_0xe3a9('0x11')][_0xe3a9('0x14')]);}logger[_0xe3a9('0x11')]('WhatsappQueueReport,\x20%s,\x20%s',_0xe40436,_0x1fef77[_0xe3a9('0x11')][_0xe3a9('0x14')]);return _0x31ad40(_0x1fef77[_0xe3a9('0x11')]['message']);}else{logger[_0xe3a9('0x15')]('WhatsappQueueReport,\x20%s,\x20%s',_0xe40436,_0xe3a9('0xd'));_0x31ad40(_0x1fef77[_0xe3a9('0x16')][_0xe3a9('0x14')]);}})[_0xe3a9('0x17')](function(_0x743956){logger['error'](_0xe3a9('0x13'),_0xe40436,_0x743956);_0x2e48ac(_0x743956);});});}exports['CreateWhatsappQueueReport']=function(_0x12722b){var _0x541b6e=this;return new Promise(function(_0x4eac84,_0x2be4ac){return db['WhatsappQueueReport']['create'](_0x12722b[_0xe3a9('0x18')],{'raw':_0x12722b['options']?_0x12722b['options']['raw']===undefined?!![]:![]:!![]})[_0xe3a9('0xc')](function(_0x53557c){logger['info'](_0xe3a9('0x19'),_0x12722b);logger[_0xe3a9('0xe')](_0xe3a9('0x19'),_0x12722b,JSON['stringify'](_0x53557c));_0x4eac84(_0x53557c);})['catch'](function(_0x517d4e){logger[_0xe3a9('0x11')](_0xe3a9('0x19'),_0x517d4e[_0xe3a9('0x14')],_0x12722b);_0x2be4ac(_0x541b6e[_0xe3a9('0x11')](0x1f4,_0x517d4e[_0xe3a9('0x14')]));});});};exports[_0xe3a9('0x1a')]=function(_0x32f7c4){var _0x4e0790=this;return new Promise(function(_0x56d0bc,_0x103511){return db['WhatsappQueueReport'][_0xe3a9('0x1b')](_0x32f7c4['body'],{'raw':_0x32f7c4['options']?_0x32f7c4[_0xe3a9('0x1c')][_0xe3a9('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x32f7c4['options']?_0x32f7c4[_0xe3a9('0x1c')][_0xe3a9('0x1e')]||null:null,'attributes':_0x32f7c4[_0xe3a9('0x1c')]?_0x32f7c4[_0xe3a9('0x1c')]['attributes']||null:null,'limit':_0x32f7c4[_0xe3a9('0x1c')]?_0x32f7c4[_0xe3a9('0x1c')][_0xe3a9('0x1f')]||null:null})['then'](function(_0x49295b){logger[_0xe3a9('0x15')](_0xe3a9('0x1a'),_0x32f7c4);logger[_0xe3a9('0xe')](_0xe3a9('0x1a'),_0x32f7c4,JSON['stringify'](_0x49295b));_0x56d0bc(_0x49295b);})[_0xe3a9('0x17')](function(_0x10d4d3){logger['error']('UpdateWhatsappQueueReport',_0x10d4d3[_0xe3a9('0x14')],_0x32f7c4);_0x103511(_0x4e0790[_0xe3a9('0x11')](0x1f4,_0x10d4d3['message']));});});};