a1be630d5c3fbf1f0d185ddb8dd5d2c63eb536e9
[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 _0x898b=['WhatsappQueueReport','create','body','options','stringify','update','attributes','limit','UpdateWhatsappQueueReport','lodash','util','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateWhatsappQueueReport'];(function(_0x46e9f2,_0xb8c5f9){var _0x2ff437=function(_0x231e71){while(--_0x231e71){_0x46e9f2['push'](_0x46e9f2['shift']());}};_0x2ff437(++_0xb8c5f9);}(_0x898b,0xa9));var _0xb898=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x898b[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xb898('0x0'));var util=require(_0xb898('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb898('0x2'));var db=require(_0xb898('0x3'))['db'];var utils=require(_0xb898('0x4'));var logger=require(_0xb898('0x5'))(_0xb898('0x6'));var config=require('../../config/environment');var jayson=require(_0xb898('0x7'));var client=jayson[_0xb898('0x8')][_0xb898('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x4dcfbb,_0xf75c19,_0x44d5a8){return new BPromise(function(_0x24c680,_0x1e7ce0){return client[_0xb898('0xa')](_0x4dcfbb,_0x44d5a8)[_0xb898('0xb')](function(_0x17b91b){logger[_0xb898('0xc')](_0xb898('0xd'),_0xf75c19,_0xb898('0xe'));logger[_0xb898('0xf')](_0xb898('0x10'),_0xf75c19,'request\x20sent',JSON['stringify'](_0x17b91b));if(_0x17b91b[_0xb898('0x11')]){if(_0x17b91b[_0xb898('0x11')][_0xb898('0x12')]===0x1f4){logger[_0xb898('0x11')](_0xb898('0xd'),_0xf75c19,_0x17b91b['error']['message']);return _0x1e7ce0(_0x17b91b[_0xb898('0x11')]['message']);}logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0xf75c19,_0x17b91b['error'][_0xb898('0x13')]);return _0x24c680(_0x17b91b['error'][_0xb898('0x13')]);}else{logger[_0xb898('0xc')](_0xb898('0xd'),_0xf75c19,_0xb898('0xe'));_0x24c680(_0x17b91b[_0xb898('0x14')]['message']);}})[_0xb898('0x15')](function(_0x4be84f){logger['error'](_0xb898('0xd'),_0xf75c19,_0x4be84f);_0x1e7ce0(_0x4be84f);});});}exports[_0xb898('0x16')]=function(_0x2fed7a){var _0x514c1f=this;return new Promise(function(_0x3554c0,_0x3fe44c){return db[_0xb898('0x17')][_0xb898('0x18')](_0x2fed7a[_0xb898('0x19')],{'raw':_0x2fed7a['options']?_0x2fed7a[_0xb898('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0xb898('0xb')](function(_0x3cb4e7){logger[_0xb898('0xc')](_0xb898('0x16'),_0x2fed7a);logger[_0xb898('0xf')]('CreateWhatsappQueueReport',_0x2fed7a,JSON[_0xb898('0x1b')](_0x3cb4e7));_0x3554c0(_0x3cb4e7);})['catch'](function(_0xc0031b){logger[_0xb898('0x11')]('CreateWhatsappQueueReport',_0xc0031b['message'],_0x2fed7a);_0x3fe44c(_0x514c1f[_0xb898('0x11')](0x1f4,_0xc0031b[_0xb898('0x13')]));});});};exports['UpdateWhatsappQueueReport']=function(_0x10d35e){var _0x8f0391=this;return new Promise(function(_0x31cb0b,_0x367373){return db[_0xb898('0x17')][_0xb898('0x1c')](_0x10d35e[_0xb898('0x19')],{'raw':_0x10d35e[_0xb898('0x1a')]?_0x10d35e[_0xb898('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x10d35e[_0xb898('0x1a')]?_0x10d35e[_0xb898('0x1a')]['where']||null:null,'attributes':_0x10d35e[_0xb898('0x1a')]?_0x10d35e[_0xb898('0x1a')][_0xb898('0x1d')]||null:null,'limit':_0x10d35e['options']?_0x10d35e[_0xb898('0x1a')][_0xb898('0x1e')]||null:null})[_0xb898('0xb')](function(_0x368dea){logger[_0xb898('0xc')](_0xb898('0x1f'),_0x10d35e);logger[_0xb898('0xf')](_0xb898('0x1f'),_0x10d35e,JSON['stringify'](_0x368dea));_0x31cb0b(_0x368dea);})[_0xb898('0x15')](function(_0x464d17){logger[_0xb898('0x11')]('UpdateWhatsappQueueReport',_0x464d17['message'],_0x10d35e);_0x367373(_0x8f0391[_0xb898('0x11')](0x1f4,_0x464d17['message']));});});};