5641787f461f662d987072b2c6c835b759866589
[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 _0x2b19=['ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','request','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateWhatsappQueueReport','WhatsappQueueReport','create','body','options','raw','then','UpdateWhatsappQueueReport','where','attributes','lodash','moment','bluebird'];(function(_0x5128ba,_0x4063f5){var _0x2cf596=function(_0x5da93a){while(--_0x5da93a){_0x5128ba['push'](_0x5128ba['shift']());}};_0x2cf596(++_0x4063f5);}(_0x2b19,0x11d));var _0x92b1=function(_0x3c5928,_0x4a7003){_0x3c5928=_0x3c5928-0x0;var _0x14e5c1=_0x2b19[_0x3c5928];return _0x14e5c1;};'use strict';var _=require(_0x92b1('0x0'));var util=require('util');var moment=require(_0x92b1('0x1'));var BPromise=require(_0x92b1('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x92b1('0x3'));var db=require(_0x92b1('0x4'))['db'];var utils=require(_0x92b1('0x5'));var logger=require(_0x92b1('0x6'))('rpc');var config=require(_0x92b1('0x7'));var jayson=require(_0x92b1('0x8'));var client=jayson[_0x92b1('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x459403,_0x161836,_0x53eca6){return new BPromise(function(_0x120c58,_0x55fef2){return client[_0x92b1('0xa')](_0x459403,_0x53eca6)['then'](function(_0x2f7d12){logger[_0x92b1('0xb')](_0x92b1('0xc'),_0x161836,_0x92b1('0xd'));logger[_0x92b1('0xe')](_0x92b1('0xf'),_0x161836,_0x92b1('0xd'),JSON[_0x92b1('0x10')](_0x2f7d12));if(_0x2f7d12[_0x92b1('0x11')]){if(_0x2f7d12[_0x92b1('0x11')][_0x92b1('0x12')]===0x1f4){logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0x161836,_0x2f7d12[_0x92b1('0x11')][_0x92b1('0x13')]);return _0x55fef2(_0x2f7d12[_0x92b1('0x11')]['message']);}logger[_0x92b1('0x11')]('WhatsappQueueReport,\x20%s,\x20%s',_0x161836,_0x2f7d12[_0x92b1('0x11')][_0x92b1('0x13')]);return _0x120c58(_0x2f7d12['error'][_0x92b1('0x13')]);}else{logger[_0x92b1('0xb')](_0x92b1('0xc'),_0x161836,_0x92b1('0xd'));_0x120c58(_0x2f7d12[_0x92b1('0x14')]['message']);}})[_0x92b1('0x15')](function(_0x33ca61){logger[_0x92b1('0x11')](_0x92b1('0xc'),_0x161836,_0x33ca61);_0x55fef2(_0x33ca61);});});}exports[_0x92b1('0x16')]=function(_0x3e603a){var _0x4da4ec=this;return new Promise(function(_0x349d5f,_0xf18915){return db[_0x92b1('0x17')][_0x92b1('0x18')](_0x3e603a[_0x92b1('0x19')],{'raw':_0x3e603a[_0x92b1('0x1a')]?_0x3e603a['options'][_0x92b1('0x1b')]===undefined?!![]:![]:!![]})[_0x92b1('0x1c')](function(_0x2ae92c){logger[_0x92b1('0xb')](_0x92b1('0x16'),_0x3e603a);logger['debug'](_0x92b1('0x16'),_0x3e603a,JSON['stringify'](_0x2ae92c));_0x349d5f(_0x2ae92c);})[_0x92b1('0x15')](function(_0x28e77d){logger[_0x92b1('0x11')](_0x92b1('0x16'),_0x28e77d['message'],_0x3e603a);_0xf18915(_0x4da4ec[_0x92b1('0x11')](0x1f4,_0x28e77d['message']));});});};exports[_0x92b1('0x1d')]=function(_0xdf788){var _0x49af16=this;return new Promise(function(_0x2c88f3,_0x218d68){return db[_0x92b1('0x17')]['update'](_0xdf788[_0x92b1('0x19')],{'raw':_0xdf788['options']?_0xdf788[_0x92b1('0x1a')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xdf788['options']?_0xdf788[_0x92b1('0x1a')][_0x92b1('0x1e')]||null:null,'attributes':_0xdf788[_0x92b1('0x1a')]?_0xdf788[_0x92b1('0x1a')][_0x92b1('0x1f')]||null:null,'limit':_0xdf788[_0x92b1('0x1a')]?_0xdf788[_0x92b1('0x1a')]['limit']||null:null})[_0x92b1('0x1c')](function(_0x5c9e17){logger[_0x92b1('0xb')]('UpdateWhatsappQueueReport',_0xdf788);logger[_0x92b1('0xe')]('UpdateWhatsappQueueReport',_0xdf788,JSON[_0x92b1('0x10')](_0x5c9e17));_0x2c88f3(_0x5c9e17);})[_0x92b1('0x15')](function(_0xf5235a){logger['error'](_0x92b1('0x1d'),_0xf5235a[_0x92b1('0x13')],_0xdf788);_0x218d68(_0x49af16[_0x92b1('0x11')](0x1f4,_0xf5235a[_0x92b1('0x13')]));});});};