Built motion from commit 44377920.|2.6.11
[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 _0x4c8d=['info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','code','error','message','result','catch','CreateWhatsappQueueReport','WhatsappQueueReport','body','options','raw','stringify','where','attributes','UpdateWhatsappQueueReport','lodash','util','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then'];(function(_0x2c8904,_0x222507){var _0xac620f=function(_0x3d0ccb){while(--_0x3d0ccb){_0x2c8904['push'](_0x2c8904['shift']());}};_0xac620f(++_0x222507);}(_0x4c8d,0x1a6));var _0xd4c8=function(_0x4e3127,_0x470bc6){_0x4e3127=_0x4e3127-0x0;var _0x16196e=_0x4c8d[_0x4e3127];return _0x16196e;};'use strict';var _=require(_0xd4c8('0x0'));var util=require(_0xd4c8('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xd4c8('0x2'));var db=require(_0xd4c8('0x3'))['db'];var utils=require(_0xd4c8('0x4'));var logger=require(_0xd4c8('0x5'))(_0xd4c8('0x6'));var config=require(_0xd4c8('0x7'));var jayson=require(_0xd4c8('0x8'));var client=jayson[_0xd4c8('0x9')][_0xd4c8('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x14ba1d,_0x381628,_0x465b34){return new BPromise(function(_0x471d3a,_0x20f52c){return client['request'](_0x14ba1d,_0x465b34)[_0xd4c8('0xb')](function(_0x3929c1){logger[_0xd4c8('0xc')](_0xd4c8('0xd'),_0x381628,_0xd4c8('0xe'));logger[_0xd4c8('0xf')](_0xd4c8('0x10'),_0x381628,_0xd4c8('0xe'),JSON['stringify'](_0x3929c1));if(_0x3929c1['error']){if(_0x3929c1['error'][_0xd4c8('0x11')]===0x1f4){logger[_0xd4c8('0x12')](_0xd4c8('0xd'),_0x381628,_0x3929c1[_0xd4c8('0x12')]['message']);return _0x20f52c(_0x3929c1[_0xd4c8('0x12')][_0xd4c8('0x13')]);}logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0x381628,_0x3929c1[_0xd4c8('0x12')]['message']);return _0x471d3a(_0x3929c1['error'][_0xd4c8('0x13')]);}else{logger[_0xd4c8('0xc')]('WhatsappQueueReport,\x20%s,\x20%s',_0x381628,_0xd4c8('0xe'));_0x471d3a(_0x3929c1[_0xd4c8('0x14')][_0xd4c8('0x13')]);}})[_0xd4c8('0x15')](function(_0x66ec4a){logger[_0xd4c8('0x12')](_0xd4c8('0xd'),_0x381628,_0x66ec4a);_0x20f52c(_0x66ec4a);});});}exports[_0xd4c8('0x16')]=function(_0x4cbd65){var _0x445519=this;return new Promise(function(_0x108d97,_0x293254){return db[_0xd4c8('0x17')]['create'](_0x4cbd65[_0xd4c8('0x18')],{'raw':_0x4cbd65[_0xd4c8('0x19')]?_0x4cbd65[_0xd4c8('0x19')][_0xd4c8('0x1a')]===undefined?!![]:![]:!![]})['then'](function(_0x4e3256){logger['info'](_0xd4c8('0x16'),_0x4cbd65);logger[_0xd4c8('0xf')](_0xd4c8('0x16'),_0x4cbd65,JSON[_0xd4c8('0x1b')](_0x4e3256));_0x108d97(_0x4e3256);})[_0xd4c8('0x15')](function(_0x59f85b){logger[_0xd4c8('0x12')](_0xd4c8('0x16'),_0x59f85b['message'],_0x4cbd65);_0x293254(_0x445519[_0xd4c8('0x12')](0x1f4,_0x59f85b[_0xd4c8('0x13')]));});});};exports['UpdateWhatsappQueueReport']=function(_0x19d1f9){var _0x23d1b4=this;return new Promise(function(_0x4c30e9,_0x888907){return db[_0xd4c8('0x17')]['update'](_0x19d1f9[_0xd4c8('0x18')],{'raw':_0x19d1f9[_0xd4c8('0x19')]?_0x19d1f9['options'][_0xd4c8('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x19d1f9[_0xd4c8('0x19')]?_0x19d1f9[_0xd4c8('0x19')][_0xd4c8('0x1c')]||null:null,'attributes':_0x19d1f9['options']?_0x19d1f9[_0xd4c8('0x19')][_0xd4c8('0x1d')]||null:null,'limit':_0x19d1f9[_0xd4c8('0x19')]?_0x19d1f9['options']['limit']||null:null})[_0xd4c8('0xb')](function(_0x259868){logger[_0xd4c8('0xc')](_0xd4c8('0x1e'),_0x19d1f9);logger[_0xd4c8('0xf')]('UpdateWhatsappQueueReport',_0x19d1f9,JSON['stringify'](_0x259868));_0x4c30e9(_0x259868);})[_0xd4c8('0x15')](function(_0x292da9){logger[_0xd4c8('0x12')](_0xd4c8('0x1e'),_0x292da9[_0xd4c8('0x13')],_0x19d1f9);_0x888907(_0x23d1b4[_0xd4c8('0x12')](0x1f4,_0x292da9[_0xd4c8('0x13')]));});});};