de3515958d625ac8814d4d21ef2e3c6bb2240919
[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 _0x3c5f=['stringify','error','code','message','request\x20sent','CreateWhatsappQueueReport','WhatsappQueueReport','create','body','options','raw','debug','catch','UpdateWhatsappQueueReport','update','attributes','limit','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','request','then','info','WhatsappQueueReport,\x20%s,\x20%s','WhatsappQueueReport,\x20%s,\x20%s,\x20%s'];(function(_0x37cdf7,_0x540a3f){var _0x68fdb4=function(_0x54071e){while(--_0x54071e){_0x37cdf7['push'](_0x37cdf7['shift']());}};_0x68fdb4(++_0x540a3f);}(_0x3c5f,0x1b1));var _0xf3c5=function(_0x5f3d2f,_0x307960){_0x5f3d2f=_0x5f3d2f-0x0;var _0xc5fc30=_0x3c5f[_0x5f3d2f];return _0xc5fc30;};'use strict';var _=require(_0xf3c5('0x0'));var util=require(_0xf3c5('0x1'));var moment=require('moment');var BPromise=require(_0xf3c5('0x2'));var rs=require(_0xf3c5('0x3'));var fs=require('fs');var Redis=require(_0xf3c5('0x4'));var db=require(_0xf3c5('0x5'))['db'];var utils=require(_0xf3c5('0x6'));var logger=require(_0xf3c5('0x7'))(_0xf3c5('0x8'));var config=require('../../config/environment');var jayson=require(_0xf3c5('0x9'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x13a57b,_0x4e7d6b,_0x437de2){return new BPromise(function(_0x1c707e,_0x5c4353){return client[_0xf3c5('0xa')](_0x13a57b,_0x437de2)[_0xf3c5('0xb')](function(_0x2b11d4){logger[_0xf3c5('0xc')](_0xf3c5('0xd'),_0x4e7d6b,'request\x20sent');logger['debug'](_0xf3c5('0xe'),_0x4e7d6b,'request\x20sent',JSON[_0xf3c5('0xf')](_0x2b11d4));if(_0x2b11d4['error']){if(_0x2b11d4[_0xf3c5('0x10')][_0xf3c5('0x11')]===0x1f4){logger['error'](_0xf3c5('0xd'),_0x4e7d6b,_0x2b11d4['error'][_0xf3c5('0x12')]);return _0x5c4353(_0x2b11d4[_0xf3c5('0x10')]['message']);}logger[_0xf3c5('0x10')](_0xf3c5('0xd'),_0x4e7d6b,_0x2b11d4[_0xf3c5('0x10')][_0xf3c5('0x12')]);return _0x1c707e(_0x2b11d4[_0xf3c5('0x10')][_0xf3c5('0x12')]);}else{logger[_0xf3c5('0xc')](_0xf3c5('0xd'),_0x4e7d6b,_0xf3c5('0x13'));_0x1c707e(_0x2b11d4['result']['message']);}})['catch'](function(_0x15ef21){logger[_0xf3c5('0x10')](_0xf3c5('0xd'),_0x4e7d6b,_0x15ef21);_0x5c4353(_0x15ef21);});});}exports[_0xf3c5('0x14')]=function(_0x4295a7){var _0x4bb23d=this;return new Promise(function(_0x789701,_0x33bf8a){return db[_0xf3c5('0x15')][_0xf3c5('0x16')](_0x4295a7[_0xf3c5('0x17')],{'raw':_0x4295a7[_0xf3c5('0x18')]?_0x4295a7[_0xf3c5('0x18')][_0xf3c5('0x19')]===undefined?!![]:![]:!![]})[_0xf3c5('0xb')](function(_0x680964){logger[_0xf3c5('0xc')](_0xf3c5('0x14'),_0x4295a7);logger[_0xf3c5('0x1a')](_0xf3c5('0x14'),_0x4295a7,JSON['stringify'](_0x680964));_0x789701(_0x680964);})[_0xf3c5('0x1b')](function(_0x434d47){logger[_0xf3c5('0x10')]('CreateWhatsappQueueReport',_0x434d47[_0xf3c5('0x12')],_0x4295a7);_0x33bf8a(_0x4bb23d[_0xf3c5('0x10')](0x1f4,_0x434d47[_0xf3c5('0x12')]));});});};exports[_0xf3c5('0x1c')]=function(_0x138c32){var _0x398dd6=this;return new Promise(function(_0x26bc40,_0x17bd66){return db['WhatsappQueueReport'][_0xf3c5('0x1d')](_0x138c32[_0xf3c5('0x17')],{'raw':_0x138c32[_0xf3c5('0x18')]?_0x138c32[_0xf3c5('0x18')][_0xf3c5('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x138c32[_0xf3c5('0x18')]?_0x138c32[_0xf3c5('0x18')]['where']||null:null,'attributes':_0x138c32[_0xf3c5('0x18')]?_0x138c32[_0xf3c5('0x18')][_0xf3c5('0x1e')]||null:null,'limit':_0x138c32[_0xf3c5('0x18')]?_0x138c32[_0xf3c5('0x18')][_0xf3c5('0x1f')]||null:null})[_0xf3c5('0xb')](function(_0x25d075){logger[_0xf3c5('0xc')](_0xf3c5('0x1c'),_0x138c32);logger[_0xf3c5('0x1a')](_0xf3c5('0x1c'),_0x138c32,JSON[_0xf3c5('0xf')](_0x25d075));_0x26bc40(_0x25d075);})[_0xf3c5('0x1b')](function(_0x79afde){logger[_0xf3c5('0x10')](_0xf3c5('0x1c'),_0x79afde['message'],_0x138c32);_0x17bd66(_0x398dd6[_0xf3c5('0x10')](0x1f4,_0x79afde[_0xf3c5('0x12')]));});});};