Built motion from commit 0415ced0.|2.6.28
[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 _0xaa69=['jayson/promise','client','http','request','then','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','UpdateWhatsappQueueReport','where','limit','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment'];(function(_0x2d6197,_0x82ebfb){var _0x4d0e75=function(_0x577e7a){while(--_0x577e7a){_0x2d6197['push'](_0x2d6197['shift']());}};_0x4d0e75(++_0x82ebfb);}(_0xaa69,0xa1));var _0x9aa6=function(_0x1d9dfe,_0x556a07){_0x1d9dfe=_0x1d9dfe-0x0;var _0x1f9c68=_0xaa69[_0x1d9dfe];return _0x1f9c68;};'use strict';var _=require(_0x9aa6('0x0'));var util=require(_0x9aa6('0x1'));var moment=require(_0x9aa6('0x2'));var BPromise=require(_0x9aa6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x9aa6('0x4'))['db'];var utils=require(_0x9aa6('0x5'));var logger=require(_0x9aa6('0x6'))(_0x9aa6('0x7'));var config=require(_0x9aa6('0x8'));var jayson=require(_0x9aa6('0x9'));var client=jayson[_0x9aa6('0xa')][_0x9aa6('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x4d38c0,_0x383fb8,_0x1fff53){return new BPromise(function(_0x351ab3,_0x38eec1){return client[_0x9aa6('0xc')](_0x4d38c0,_0x1fff53)[_0x9aa6('0xd')](function(_0x4de47c){logger[_0x9aa6('0xe')](_0x9aa6('0xf'),_0x383fb8,_0x9aa6('0x10'));logger[_0x9aa6('0x11')](_0x9aa6('0x12'),_0x383fb8,_0x9aa6('0x10'),JSON[_0x9aa6('0x13')](_0x4de47c));if(_0x4de47c[_0x9aa6('0x14')]){if(_0x4de47c[_0x9aa6('0x14')][_0x9aa6('0x15')]===0x1f4){logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0x383fb8,_0x4de47c[_0x9aa6('0x14')]['message']);return _0x38eec1(_0x4de47c[_0x9aa6('0x14')][_0x9aa6('0x16')]);}logger['error'](_0x9aa6('0xf'),_0x383fb8,_0x4de47c[_0x9aa6('0x14')][_0x9aa6('0x16')]);return _0x351ab3(_0x4de47c[_0x9aa6('0x14')][_0x9aa6('0x16')]);}else{logger[_0x9aa6('0xe')](_0x9aa6('0xf'),_0x383fb8,_0x9aa6('0x10'));_0x351ab3(_0x4de47c[_0x9aa6('0x17')][_0x9aa6('0x16')]);}})[_0x9aa6('0x18')](function(_0x580189){logger['error'](_0x9aa6('0xf'),_0x383fb8,_0x580189);_0x38eec1(_0x580189);});});}exports[_0x9aa6('0x19')]=function(_0x326e78){var _0x19848d=this;return new Promise(function(_0x1414ae,_0x3c991e){return db[_0x9aa6('0x1a')][_0x9aa6('0x1b')](_0x326e78[_0x9aa6('0x1c')],{'raw':_0x326e78[_0x9aa6('0x1d')]?_0x326e78[_0x9aa6('0x1d')][_0x9aa6('0x1e')]===undefined?!![]:![]:!![]})[_0x9aa6('0xd')](function(_0x4cf581){logger[_0x9aa6('0xe')](_0x9aa6('0x19'),_0x326e78);logger['debug'](_0x9aa6('0x19'),_0x326e78,JSON[_0x9aa6('0x13')](_0x4cf581));_0x1414ae(_0x4cf581);})[_0x9aa6('0x18')](function(_0x3ff97f){logger[_0x9aa6('0x14')](_0x9aa6('0x19'),_0x3ff97f[_0x9aa6('0x16')],_0x326e78);_0x3c991e(_0x19848d['error'](0x1f4,_0x3ff97f[_0x9aa6('0x16')]));});});};exports[_0x9aa6('0x1f')]=function(_0xe3477a){var _0x11f7c6=this;return new Promise(function(_0x17d8d6,_0x39b62f){return db['WhatsappQueueReport']['update'](_0xe3477a[_0x9aa6('0x1c')],{'raw':_0xe3477a[_0x9aa6('0x1d')]?_0xe3477a[_0x9aa6('0x1d')][_0x9aa6('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xe3477a['options']?_0xe3477a['options'][_0x9aa6('0x20')]||null:null,'attributes':_0xe3477a[_0x9aa6('0x1d')]?_0xe3477a['options']['attributes']||null:null,'limit':_0xe3477a[_0x9aa6('0x1d')]?_0xe3477a['options'][_0x9aa6('0x21')]||null:null})['then'](function(_0x42eaf8){logger['info'](_0x9aa6('0x1f'),_0xe3477a);logger['debug']('UpdateWhatsappQueueReport',_0xe3477a,JSON[_0x9aa6('0x13')](_0x42eaf8));_0x17d8d6(_0x42eaf8);})[_0x9aa6('0x18')](function(_0x1874c4){logger[_0x9aa6('0x14')](_0x9aa6('0x1f'),_0x1874c4[_0x9aa6('0x16')],_0xe3477a);_0x39b62f(_0x11f7c6['error'](0x1f4,_0x1874c4[_0x9aa6('0x16')]));});});};