c28c20ea4a0881e2ea3d7b7a9a61a34f53f4a185
[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 _0x9b37=['moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','then','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','WhatsappQueueReport','create','body','options','raw','info','CreateWhatsappQueueReport','UpdateWhatsappQueueReport','update','where','attributes','limit','lodash','util'];(function(_0x1149ac,_0x580f0d){var _0x2add38=function(_0x67e818){while(--_0x67e818){_0x1149ac['push'](_0x1149ac['shift']());}};_0x2add38(++_0x580f0d);}(_0x9b37,0x170));var _0x79b3=function(_0x4b784d,_0x5efb2f){_0x4b784d=_0x4b784d-0x0;var _0x2cdeaf=_0x9b37[_0x4b784d];return _0x2cdeaf;};'use strict';var _=require(_0x79b3('0x0'));var util=require(_0x79b3('0x1'));var moment=require(_0x79b3('0x2'));var BPromise=require(_0x79b3('0x3'));var rs=require(_0x79b3('0x4'));var fs=require('fs');var Redis=require(_0x79b3('0x5'));var db=require(_0x79b3('0x6'))['db'];var utils=require(_0x79b3('0x7'));var logger=require(_0x79b3('0x8'))(_0x79b3('0x9'));var config=require(_0x79b3('0xa'));var jayson=require(_0x79b3('0xb'));var client=jayson[_0x79b3('0xc')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5a2529,_0x39d118,_0x314c8c){return new BPromise(function(_0x31f583,_0x1e3136){return client[_0x79b3('0xd')](_0x5a2529,_0x314c8c)[_0x79b3('0xe')](function(_0x5d8f7c){logger['info'](_0x79b3('0xf'),_0x39d118,_0x79b3('0x10'));logger[_0x79b3('0x11')](_0x79b3('0x12'),_0x39d118,_0x79b3('0x10'),JSON[_0x79b3('0x13')](_0x5d8f7c));if(_0x5d8f7c[_0x79b3('0x14')]){if(_0x5d8f7c['error'][_0x79b3('0x15')]===0x1f4){logger[_0x79b3('0x14')](_0x79b3('0xf'),_0x39d118,_0x5d8f7c[_0x79b3('0x14')][_0x79b3('0x16')]);return _0x1e3136(_0x5d8f7c[_0x79b3('0x14')][_0x79b3('0x16')]);}logger[_0x79b3('0x14')]('WhatsappQueueReport,\x20%s,\x20%s',_0x39d118,_0x5d8f7c[_0x79b3('0x14')][_0x79b3('0x16')]);return _0x31f583(_0x5d8f7c['error'][_0x79b3('0x16')]);}else{logger['info'](_0x79b3('0xf'),_0x39d118,_0x79b3('0x10'));_0x31f583(_0x5d8f7c[_0x79b3('0x17')][_0x79b3('0x16')]);}})[_0x79b3('0x18')](function(_0x219834){logger[_0x79b3('0x14')](_0x79b3('0xf'),_0x39d118,_0x219834);_0x1e3136(_0x219834);});});}exports['CreateWhatsappQueueReport']=function(_0x5eb981){var _0x146d5b=this;return new Promise(function(_0x41316e,_0x553691){return db[_0x79b3('0x19')][_0x79b3('0x1a')](_0x5eb981[_0x79b3('0x1b')],{'raw':_0x5eb981['options']?_0x5eb981[_0x79b3('0x1c')][_0x79b3('0x1d')]===undefined?!![]:![]:!![]})['then'](function(_0x34f893){logger[_0x79b3('0x1e')](_0x79b3('0x1f'),_0x5eb981);logger[_0x79b3('0x11')](_0x79b3('0x1f'),_0x5eb981,JSON[_0x79b3('0x13')](_0x34f893));_0x41316e(_0x34f893);})['catch'](function(_0x5be18e){logger['error'](_0x79b3('0x1f'),_0x5be18e[_0x79b3('0x16')],_0x5eb981);_0x553691(_0x146d5b[_0x79b3('0x14')](0x1f4,_0x5be18e[_0x79b3('0x16')]));});});};exports[_0x79b3('0x20')]=function(_0x5c4dbf){var _0x467629=this;return new Promise(function(_0x3d6894,_0x1e50ea){return db[_0x79b3('0x19')][_0x79b3('0x21')](_0x5c4dbf[_0x79b3('0x1b')],{'raw':_0x5c4dbf[_0x79b3('0x1c')]?_0x5c4dbf[_0x79b3('0x1c')][_0x79b3('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5c4dbf['options']?_0x5c4dbf[_0x79b3('0x1c')][_0x79b3('0x22')]||null:null,'attributes':_0x5c4dbf['options']?_0x5c4dbf[_0x79b3('0x1c')][_0x79b3('0x23')]||null:null,'limit':_0x5c4dbf['options']?_0x5c4dbf[_0x79b3('0x1c')][_0x79b3('0x24')]||null:null})['then'](function(_0x4e2589){logger[_0x79b3('0x1e')]('UpdateWhatsappQueueReport',_0x5c4dbf);logger[_0x79b3('0x11')](_0x79b3('0x20'),_0x5c4dbf,JSON[_0x79b3('0x13')](_0x4e2589));_0x3d6894(_0x4e2589);})[_0x79b3('0x18')](function(_0x1a2216){logger['error']('UpdateWhatsappQueueReport',_0x1a2216[_0x79b3('0x16')],_0x5c4dbf);_0x1e50ea(_0x467629['error'](0x1f4,_0x1a2216['message']));});});};