02dad0bd94b6bd7234898a0fc287b941093481f8
[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 _0xa5e8=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','CreateWhatsappQueueReport','WhatsappQueueReport','body','options','raw','debug','UpdateWhatsappQueueReport','attributes','limit','lodash','util'];(function(_0x4bbdd8,_0x358912){var _0xe25946=function(_0x2868ba){while(--_0x2868ba){_0x4bbdd8['push'](_0x4bbdd8['shift']());}};_0xe25946(++_0x358912);}(_0xa5e8,0x130));var _0x8a5e=function(_0x402f93,_0x151360){_0x402f93=_0x402f93-0x0;var _0x54feba=_0xa5e8[_0x402f93];return _0x54feba;};'use strict';var _=require(_0x8a5e('0x0'));var util=require(_0x8a5e('0x1'));var moment=require(_0x8a5e('0x2'));var BPromise=require(_0x8a5e('0x3'));var rs=require(_0x8a5e('0x4'));var fs=require('fs');var Redis=require(_0x8a5e('0x5'));var db=require(_0x8a5e('0x6'))['db'];var utils=require(_0x8a5e('0x7'));var logger=require(_0x8a5e('0x8'))(_0x8a5e('0x9'));var config=require(_0x8a5e('0xa'));var jayson=require(_0x8a5e('0xb'));var client=jayson[_0x8a5e('0xc')][_0x8a5e('0xd')]({'port':0x232a});function respondWithRpcPromise(_0x162dee,_0x17cf6b,_0x30d17a){return new BPromise(function(_0x52929d,_0x5a3571){return client[_0x8a5e('0xe')](_0x162dee,_0x30d17a)[_0x8a5e('0xf')](function(_0x2a1540){logger[_0x8a5e('0x10')](_0x8a5e('0x11'),_0x17cf6b,_0x8a5e('0x12'));logger['debug']('WhatsappQueueReport,\x20%s,\x20%s,\x20%s',_0x17cf6b,_0x8a5e('0x12'),JSON[_0x8a5e('0x13')](_0x2a1540));if(_0x2a1540[_0x8a5e('0x14')]){if(_0x2a1540[_0x8a5e('0x14')][_0x8a5e('0x15')]===0x1f4){logger['error'](_0x8a5e('0x11'),_0x17cf6b,_0x2a1540['error'][_0x8a5e('0x16')]);return _0x5a3571(_0x2a1540['error'][_0x8a5e('0x16')]);}logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0x17cf6b,_0x2a1540[_0x8a5e('0x14')][_0x8a5e('0x16')]);return _0x52929d(_0x2a1540[_0x8a5e('0x14')][_0x8a5e('0x16')]);}else{logger[_0x8a5e('0x10')]('WhatsappQueueReport,\x20%s,\x20%s',_0x17cf6b,'request\x20sent');_0x52929d(_0x2a1540[_0x8a5e('0x17')][_0x8a5e('0x16')]);}})[_0x8a5e('0x18')](function(_0xd845e1){logger[_0x8a5e('0x14')]('WhatsappQueueReport,\x20%s,\x20%s',_0x17cf6b,_0xd845e1);_0x5a3571(_0xd845e1);});});}exports[_0x8a5e('0x19')]=function(_0x2529cc){var _0x5e7f0b=this;return new Promise(function(_0x456b26,_0x5295a3){return db[_0x8a5e('0x1a')]['create'](_0x2529cc[_0x8a5e('0x1b')],{'raw':_0x2529cc[_0x8a5e('0x1c')]?_0x2529cc[_0x8a5e('0x1c')][_0x8a5e('0x1d')]===undefined?!![]:![]:!![]})['then'](function(_0x1b0485){logger['info'](_0x8a5e('0x19'),_0x2529cc);logger[_0x8a5e('0x1e')](_0x8a5e('0x19'),_0x2529cc,JSON[_0x8a5e('0x13')](_0x1b0485));_0x456b26(_0x1b0485);})[_0x8a5e('0x18')](function(_0x1e4a21){logger[_0x8a5e('0x14')]('CreateWhatsappQueueReport',_0x1e4a21[_0x8a5e('0x16')],_0x2529cc);_0x5295a3(_0x5e7f0b[_0x8a5e('0x14')](0x1f4,_0x1e4a21[_0x8a5e('0x16')]));});});};exports[_0x8a5e('0x1f')]=function(_0xf74fc1){var _0xa317c8=this;return new Promise(function(_0x20f6bf,_0x1175f2){return db[_0x8a5e('0x1a')]['update'](_0xf74fc1[_0x8a5e('0x1b')],{'raw':_0xf74fc1[_0x8a5e('0x1c')]?_0xf74fc1[_0x8a5e('0x1c')][_0x8a5e('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xf74fc1[_0x8a5e('0x1c')]?_0xf74fc1[_0x8a5e('0x1c')]['where']||null:null,'attributes':_0xf74fc1[_0x8a5e('0x1c')]?_0xf74fc1[_0x8a5e('0x1c')][_0x8a5e('0x20')]||null:null,'limit':_0xf74fc1[_0x8a5e('0x1c')]?_0xf74fc1[_0x8a5e('0x1c')][_0x8a5e('0x21')]||null:null})['then'](function(_0x177cb7){logger[_0x8a5e('0x10')](_0x8a5e('0x1f'),_0xf74fc1);logger[_0x8a5e('0x1e')](_0x8a5e('0x1f'),_0xf74fc1,JSON[_0x8a5e('0x13')](_0x177cb7));_0x20f6bf(_0x177cb7);})[_0x8a5e('0x18')](function(_0xd4a3fb){logger['error'](_0x8a5e('0x1f'),_0xd4a3fb[_0x8a5e('0x16')],_0xf74fc1);_0x1175f2(_0xa317c8['error'](0x1f4,_0xd4a3fb['message']));});});};