71b81fe871e76bc487dc063257358e27f56d6067
[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 _0x16f3=['bluebird','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','info','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','WhatsappQueueReport,\x20%s,\x20%s','message','result','WhatsappQueueReport','create','body','options','then','CreateWhatsappQueueReport','debug','catch','update','where','attributes','UpdateWhatsappQueueReport','lodash','moment'];(function(_0x5b70c7,_0x36448d){var _0x574120=function(_0x7c02b6){while(--_0x7c02b6){_0x5b70c7['push'](_0x5b70c7['shift']());}};_0x574120(++_0x36448d);}(_0x16f3,0x191));var _0x316f=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x16f3[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x316f('0x0'));var util=require('util');var moment=require(_0x316f('0x1'));var BPromise=require(_0x316f('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x316f('0x3'));var db=require(_0x316f('0x4'))['db'];var utils=require(_0x316f('0x5'));var logger=require('../../config/logger')(_0x316f('0x6'));var config=require(_0x316f('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x316f('0x8')][_0x316f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3d48b5,_0x22df63,_0x2669e7){return new BPromise(function(_0x2f2fb9,_0x4d05c0){return client['request'](_0x3d48b5,_0x2669e7)['then'](function(_0x5212d7){logger[_0x316f('0xa')]('WhatsappQueueReport,\x20%s,\x20%s',_0x22df63,'request\x20sent');logger['debug'](_0x316f('0xb'),_0x22df63,_0x316f('0xc'),JSON[_0x316f('0xd')](_0x5212d7));if(_0x5212d7[_0x316f('0xe')]){if(_0x5212d7[_0x316f('0xe')][_0x316f('0xf')]===0x1f4){logger[_0x316f('0xe')](_0x316f('0x10'),_0x22df63,_0x5212d7[_0x316f('0xe')]['message']);return _0x4d05c0(_0x5212d7['error'][_0x316f('0x11')]);}logger[_0x316f('0xe')](_0x316f('0x10'),_0x22df63,_0x5212d7[_0x316f('0xe')]['message']);return _0x2f2fb9(_0x5212d7[_0x316f('0xe')][_0x316f('0x11')]);}else{logger[_0x316f('0xa')]('WhatsappQueueReport,\x20%s,\x20%s',_0x22df63,_0x316f('0xc'));_0x2f2fb9(_0x5212d7[_0x316f('0x12')][_0x316f('0x11')]);}})['catch'](function(_0xcccaae){logger[_0x316f('0xe')]('WhatsappQueueReport,\x20%s,\x20%s',_0x22df63,_0xcccaae);_0x4d05c0(_0xcccaae);});});}exports['CreateWhatsappQueueReport']=function(_0x1ecbcc){var _0x1e6537=this;return new Promise(function(_0x59b9cc,_0x5ad706){return db[_0x316f('0x13')][_0x316f('0x14')](_0x1ecbcc[_0x316f('0x15')],{'raw':_0x1ecbcc[_0x316f('0x16')]?_0x1ecbcc[_0x316f('0x16')]['raw']===undefined?!![]:![]:!![]})[_0x316f('0x17')](function(_0x2d6da2){logger[_0x316f('0xa')](_0x316f('0x18'),_0x1ecbcc);logger[_0x316f('0x19')](_0x316f('0x18'),_0x1ecbcc,JSON[_0x316f('0xd')](_0x2d6da2));_0x59b9cc(_0x2d6da2);})[_0x316f('0x1a')](function(_0x17b854){logger[_0x316f('0xe')](_0x316f('0x18'),_0x17b854[_0x316f('0x11')],_0x1ecbcc);_0x5ad706(_0x1e6537['error'](0x1f4,_0x17b854[_0x316f('0x11')]));});});};exports['UpdateWhatsappQueueReport']=function(_0x1c222b){var _0x1dfdcd=this;return new Promise(function(_0x20483c,_0x3b3213){return db[_0x316f('0x13')][_0x316f('0x1b')](_0x1c222b[_0x316f('0x15')],{'raw':_0x1c222b[_0x316f('0x16')]?_0x1c222b['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1c222b[_0x316f('0x16')]?_0x1c222b[_0x316f('0x16')][_0x316f('0x1c')]||null:null,'attributes':_0x1c222b[_0x316f('0x16')]?_0x1c222b['options'][_0x316f('0x1d')]||null:null,'limit':_0x1c222b[_0x316f('0x16')]?_0x1c222b['options']['limit']||null:null})['then'](function(_0x2e878b){logger[_0x316f('0xa')](_0x316f('0x1e'),_0x1c222b);logger['debug'](_0x316f('0x1e'),_0x1c222b,JSON[_0x316f('0xd')](_0x2e878b));_0x20483c(_0x2e878b);})[_0x316f('0x1a')](function(_0x275d0b){logger['error'](_0x316f('0x1e'),_0x275d0b['message'],_0x1c222b);_0x3b3213(_0x1dfdcd[_0x316f('0xe')](0x1f4,_0x275d0b[_0x316f('0x11')]));});});};