eb8ebaf2f4178e7d222e1d78ba9165e92440db97
[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 _0xff83=['body','options','raw','CreateWhatsappQueueReport','UpdateWhatsappQueueReport','update','attributes','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','client','request','then','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','WhatsappQueueReport'];(function(_0x2289b3,_0x437045){var _0x5ca1f5=function(_0x5140a8){while(--_0x5140a8){_0x2289b3['push'](_0x2289b3['shift']());}};_0x5ca1f5(++_0x437045);}(_0xff83,0x98));var _0x3ff8=function(_0x2b10c6,_0x185590){_0x2b10c6=_0x2b10c6-0x0;var _0x3789d2=_0xff83[_0x2b10c6];return _0x3789d2;};'use strict';var _=require('lodash');var util=require(_0x3ff8('0x0'));var moment=require(_0x3ff8('0x1'));var BPromise=require(_0x3ff8('0x2'));var rs=require(_0x3ff8('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x3ff8('0x4'));var logger=require(_0x3ff8('0x5'))(_0x3ff8('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x3ff8('0x7')]['http']({'port':0x232a});function respondWithRpcPromise(_0x49f70f,_0x493ce5,_0x65158c){return new BPromise(function(_0x184b3f,_0x278a17){return client[_0x3ff8('0x8')](_0x49f70f,_0x65158c)[_0x3ff8('0x9')](function(_0x2062c9){logger['info'](_0x3ff8('0xa'),_0x493ce5,_0x3ff8('0xb'));logger[_0x3ff8('0xc')](_0x3ff8('0xd'),_0x493ce5,_0x3ff8('0xb'),JSON[_0x3ff8('0xe')](_0x2062c9));if(_0x2062c9[_0x3ff8('0xf')]){if(_0x2062c9['error'][_0x3ff8('0x10')]===0x1f4){logger['error'](_0x3ff8('0xa'),_0x493ce5,_0x2062c9[_0x3ff8('0xf')][_0x3ff8('0x11')]);return _0x278a17(_0x2062c9[_0x3ff8('0xf')][_0x3ff8('0x11')]);}logger[_0x3ff8('0xf')](_0x3ff8('0xa'),_0x493ce5,_0x2062c9[_0x3ff8('0xf')][_0x3ff8('0x11')]);return _0x184b3f(_0x2062c9[_0x3ff8('0xf')][_0x3ff8('0x11')]);}else{logger[_0x3ff8('0x12')](_0x3ff8('0xa'),_0x493ce5,_0x3ff8('0xb'));_0x184b3f(_0x2062c9[_0x3ff8('0x13')]['message']);}})[_0x3ff8('0x14')](function(_0x7b666c){logger[_0x3ff8('0xf')](_0x3ff8('0xa'),_0x493ce5,_0x7b666c);_0x278a17(_0x7b666c);});});}exports['CreateWhatsappQueueReport']=function(_0x3741a0){var _0x4c9901=this;return new Promise(function(_0xaf76d5,_0x1d29bc){return db[_0x3ff8('0x15')]['create'](_0x3741a0[_0x3ff8('0x16')],{'raw':_0x3741a0[_0x3ff8('0x17')]?_0x3741a0[_0x3ff8('0x17')][_0x3ff8('0x18')]===undefined?!![]:![]:!![]})['then'](function(_0x16a4b0){logger[_0x3ff8('0x12')](_0x3ff8('0x19'),_0x3741a0);logger['debug']('CreateWhatsappQueueReport',_0x3741a0,JSON[_0x3ff8('0xe')](_0x16a4b0));_0xaf76d5(_0x16a4b0);})[_0x3ff8('0x14')](function(_0xd23441){logger[_0x3ff8('0xf')](_0x3ff8('0x19'),_0xd23441[_0x3ff8('0x11')],_0x3741a0);_0x1d29bc(_0x4c9901[_0x3ff8('0xf')](0x1f4,_0xd23441[_0x3ff8('0x11')]));});});};exports[_0x3ff8('0x1a')]=function(_0x42f214){var _0x4338c8=this;return new Promise(function(_0x1c95fb,_0x573564){return db[_0x3ff8('0x15')][_0x3ff8('0x1b')](_0x42f214[_0x3ff8('0x16')],{'raw':_0x42f214[_0x3ff8('0x17')]?_0x42f214[_0x3ff8('0x17')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x42f214['options']?_0x42f214[_0x3ff8('0x17')]['where']||null:null,'attributes':_0x42f214[_0x3ff8('0x17')]?_0x42f214[_0x3ff8('0x17')][_0x3ff8('0x1c')]||null:null,'limit':_0x42f214[_0x3ff8('0x17')]?_0x42f214[_0x3ff8('0x17')]['limit']||null:null})['then'](function(_0x480ea2){logger[_0x3ff8('0x12')](_0x3ff8('0x1a'),_0x42f214);logger[_0x3ff8('0xc')](_0x3ff8('0x1a'),_0x42f214,JSON[_0x3ff8('0xe')](_0x480ea2));_0x1c95fb(_0x480ea2);})[_0x3ff8('0x14')](function(_0x348ffa){logger[_0x3ff8('0xf')](_0x3ff8('0x1a'),_0x348ffa['message'],_0x42f214);_0x573564(_0x4338c8[_0x3ff8('0xf')](0x1f4,_0x348ffa[_0x3ff8('0x11')]));});});};