dc2953c741ef9ec95ea7ac8a28d130db897d1de0
[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 _0x4507=['bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','info','WhatsappQueueReport,\x20%s,\x20%s','request\x20sent','debug','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateWhatsappQueueReport','WhatsappQueueReport','create','body','options','raw','stringify','update','where','attributes','limit','UpdateWhatsappQueueReport','lodash','util','moment'];(function(_0xe36d1c,_0x3973d5){var _0x1d2298=function(_0x2ed1c5){while(--_0x2ed1c5){_0xe36d1c['push'](_0xe36d1c['shift']());}};_0x1d2298(++_0x3973d5);}(_0x4507,0x165));var _0x7450=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0x4507[_0x42cae2];return _0x5f256f;};'use strict';var _=require(_0x7450('0x0'));var util=require(_0x7450('0x1'));var moment=require(_0x7450('0x2'));var BPromise=require(_0x7450('0x3'));var rs=require(_0x7450('0x4'));var fs=require('fs');var Redis=require(_0x7450('0x5'));var db=require(_0x7450('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x7450('0x7'))(_0x7450('0x8'));var config=require(_0x7450('0x9'));var jayson=require(_0x7450('0xa'));var client=jayson[_0x7450('0xb')][_0x7450('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x39b7d7,_0x5eb94b,_0x5c12e6){return new BPromise(function(_0x109e4d,_0x211338){return client['request'](_0x39b7d7,_0x5c12e6)[_0x7450('0xd')](function(_0x5572b9){logger[_0x7450('0xe')](_0x7450('0xf'),_0x5eb94b,_0x7450('0x10'));logger[_0x7450('0x11')](_0x7450('0x12'),_0x5eb94b,_0x7450('0x10'),JSON['stringify'](_0x5572b9));if(_0x5572b9['error']){if(_0x5572b9[_0x7450('0x13')][_0x7450('0x14')]===0x1f4){logger[_0x7450('0x13')](_0x7450('0xf'),_0x5eb94b,_0x5572b9[_0x7450('0x13')][_0x7450('0x15')]);return _0x211338(_0x5572b9[_0x7450('0x13')][_0x7450('0x15')]);}logger[_0x7450('0x13')]('WhatsappQueueReport,\x20%s,\x20%s',_0x5eb94b,_0x5572b9[_0x7450('0x13')]['message']);return _0x109e4d(_0x5572b9[_0x7450('0x13')][_0x7450('0x15')]);}else{logger[_0x7450('0xe')]('WhatsappQueueReport,\x20%s,\x20%s',_0x5eb94b,'request\x20sent');_0x109e4d(_0x5572b9[_0x7450('0x16')][_0x7450('0x15')]);}})[_0x7450('0x17')](function(_0xd10392){logger['error']('WhatsappQueueReport,\x20%s,\x20%s',_0x5eb94b,_0xd10392);_0x211338(_0xd10392);});});}exports[_0x7450('0x18')]=function(_0x44d65c){var _0x5c7e7d=this;return new Promise(function(_0x4c0bf0,_0x37c133){return db[_0x7450('0x19')][_0x7450('0x1a')](_0x44d65c[_0x7450('0x1b')],{'raw':_0x44d65c[_0x7450('0x1c')]?_0x44d65c[_0x7450('0x1c')][_0x7450('0x1d')]===undefined?!![]:![]:!![]})['then'](function(_0x5c7b9b){logger[_0x7450('0xe')](_0x7450('0x18'),_0x44d65c);logger['debug']('CreateWhatsappQueueReport',_0x44d65c,JSON[_0x7450('0x1e')](_0x5c7b9b));_0x4c0bf0(_0x5c7b9b);})[_0x7450('0x17')](function(_0x227f14){logger[_0x7450('0x13')](_0x7450('0x18'),_0x227f14['message'],_0x44d65c);_0x37c133(_0x5c7e7d['error'](0x1f4,_0x227f14['message']));});});};exports['UpdateWhatsappQueueReport']=function(_0x405778){var _0x13915a=this;return new Promise(function(_0x5f214f,_0x5ef0eb){return db['WhatsappQueueReport'][_0x7450('0x1f')](_0x405778[_0x7450('0x1b')],{'raw':_0x405778['options']?_0x405778['options'][_0x7450('0x1d')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x405778[_0x7450('0x1c')]?_0x405778[_0x7450('0x1c')][_0x7450('0x20')]||null:null,'attributes':_0x405778['options']?_0x405778[_0x7450('0x1c')][_0x7450('0x21')]||null:null,'limit':_0x405778[_0x7450('0x1c')]?_0x405778[_0x7450('0x1c')][_0x7450('0x22')]||null:null})[_0x7450('0xd')](function(_0x5791c8){logger[_0x7450('0xe')](_0x7450('0x23'),_0x405778);logger['debug'](_0x7450('0x23'),_0x405778,JSON[_0x7450('0x1e')](_0x5791c8));_0x5f214f(_0x5791c8);})[_0x7450('0x17')](function(_0x58dc5b){logger[_0x7450('0x13')](_0x7450('0x23'),_0x58dc5b['message'],_0x405778);_0x5ef0eb(_0x13915a[_0x7450('0x13')](0x1f4,_0x58dc5b[_0x7450('0x15')]));});});};