9c750996cedcdbd36187b0a408a2c3421763d6f7
[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 _0xb40c=['rpc','jayson/promise','client','request','then','info','request\x20sent','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappQueueReport,\x20%s,\x20%s','message','result','CreateWhatsappQueueReport','WhatsappQueueReport','create','body','options','debug','catch','UpdateWhatsappQueueReport','raw','where','attributes','limit','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x36c5b0,_0x5001da){var _0xf19333=function(_0x1e880a){while(--_0x1e880a){_0x36c5b0['push'](_0x36c5b0['shift']());}};_0xf19333(++_0x5001da);}(_0xb40c,0x143));var _0xcb40=function(_0x423405,_0x55e2a4){_0x423405=_0x423405-0x0;var _0x3247e3=_0xb40c[_0x423405];return _0x3247e3;};'use strict';var _=require('lodash');var util=require(_0xcb40('0x0'));var moment=require(_0xcb40('0x1'));var BPromise=require('bluebird');var rs=require(_0xcb40('0x2'));var fs=require('fs');var Redis=require(_0xcb40('0x3'));var db=require(_0xcb40('0x4'))['db'];var utils=require(_0xcb40('0x5'));var logger=require(_0xcb40('0x6'))(_0xcb40('0x7'));var config=require('../../config/environment');var jayson=require(_0xcb40('0x8'));var client=jayson[_0xcb40('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x56aa2d,_0xc273a6,_0x54dfdd){return new BPromise(function(_0x4db1be,_0x31152a){return client[_0xcb40('0xa')](_0x56aa2d,_0x54dfdd)[_0xcb40('0xb')](function(_0x417ad4){logger[_0xcb40('0xc')]('WhatsappQueueReport,\x20%s,\x20%s',_0xc273a6,_0xcb40('0xd'));logger['debug'](_0xcb40('0xe'),_0xc273a6,'request\x20sent',JSON[_0xcb40('0xf')](_0x417ad4));if(_0x417ad4[_0xcb40('0x10')]){if(_0x417ad4[_0xcb40('0x10')][_0xcb40('0x11')]===0x1f4){logger[_0xcb40('0x10')](_0xcb40('0x12'),_0xc273a6,_0x417ad4[_0xcb40('0x10')][_0xcb40('0x13')]);return _0x31152a(_0x417ad4['error'][_0xcb40('0x13')]);}logger[_0xcb40('0x10')](_0xcb40('0x12'),_0xc273a6,_0x417ad4[_0xcb40('0x10')]['message']);return _0x4db1be(_0x417ad4[_0xcb40('0x10')][_0xcb40('0x13')]);}else{logger[_0xcb40('0xc')](_0xcb40('0x12'),_0xc273a6,_0xcb40('0xd'));_0x4db1be(_0x417ad4[_0xcb40('0x14')]['message']);}})['catch'](function(_0x13af60){logger[_0xcb40('0x10')]('WhatsappQueueReport,\x20%s,\x20%s',_0xc273a6,_0x13af60);_0x31152a(_0x13af60);});});}exports[_0xcb40('0x15')]=function(_0x2d4ffc){var _0xb9e0e0=this;return new Promise(function(_0x53808e,_0x39d593){return db[_0xcb40('0x16')][_0xcb40('0x17')](_0x2d4ffc[_0xcb40('0x18')],{'raw':_0x2d4ffc[_0xcb40('0x19')]?_0x2d4ffc[_0xcb40('0x19')]['raw']===undefined?!![]:![]:!![]})[_0xcb40('0xb')](function(_0x285c02){logger[_0xcb40('0xc')](_0xcb40('0x15'),_0x2d4ffc);logger[_0xcb40('0x1a')](_0xcb40('0x15'),_0x2d4ffc,JSON[_0xcb40('0xf')](_0x285c02));_0x53808e(_0x285c02);})[_0xcb40('0x1b')](function(_0x12c652){logger[_0xcb40('0x10')](_0xcb40('0x15'),_0x12c652[_0xcb40('0x13')],_0x2d4ffc);_0x39d593(_0xb9e0e0['error'](0x1f4,_0x12c652[_0xcb40('0x13')]));});});};exports[_0xcb40('0x1c')]=function(_0xde3a8c){var _0x3df04c=this;return new Promise(function(_0xee18ec,_0x447e49){return db['WhatsappQueueReport']['update'](_0xde3a8c[_0xcb40('0x18')],{'raw':_0xde3a8c[_0xcb40('0x19')]?_0xde3a8c['options'][_0xcb40('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xde3a8c[_0xcb40('0x19')]?_0xde3a8c[_0xcb40('0x19')][_0xcb40('0x1e')]||null:null,'attributes':_0xde3a8c[_0xcb40('0x19')]?_0xde3a8c[_0xcb40('0x19')][_0xcb40('0x1f')]||null:null,'limit':_0xde3a8c['options']?_0xde3a8c[_0xcb40('0x19')][_0xcb40('0x20')]||null:null})['then'](function(_0xa213a6){logger['info'](_0xcb40('0x1c'),_0xde3a8c);logger[_0xcb40('0x1a')](_0xcb40('0x1c'),_0xde3a8c,JSON[_0xcb40('0xf')](_0xa213a6));_0xee18ec(_0xa213a6);})[_0xcb40('0x1b')](function(_0x3e5c9a){logger[_0xcb40('0x10')](_0xcb40('0x1c'),_0x3e5c9a[_0xcb40('0x13')],_0xde3a8c);_0x447e49(_0x3df04c['error'](0x1f4,_0x3e5c9a['message']));});});};