53f2d547ba3bc4c78733d5520f95d69bcf3eba42
[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 _0xf506=['then','info','request\x20sent','WhatsappQueueReport,\x20%s,\x20%s,\x20%s','stringify','error','code','WhatsappQueueReport,\x20%s,\x20%s','message','result','catch','WhatsappQueueReport','body','options','raw','debug','CreateWhatsappQueueReport','update','where','attributes','limit','UpdateWhatsappQueueReport','lodash','util','moment','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','client','http'];(function(_0x3574f0,_0x5e1850){var _0x931b71=function(_0x3794c8){while(--_0x3794c8){_0x3574f0['push'](_0x3574f0['shift']());}};_0x931b71(++_0x5e1850);}(_0xf506,0xd6));var _0x6f50=function(_0x4d893a,_0x413399){_0x4d893a=_0x4d893a-0x0;var _0x2a2eed=_0xf506[_0x4d893a];return _0x2a2eed;};'use strict';var _=require(_0x6f50('0x0'));var util=require(_0x6f50('0x1'));var moment=require(_0x6f50('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6f50('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x6f50('0x4'));var logger=require(_0x6f50('0x5'))(_0x6f50('0x6'));var config=require('../../config/environment');var jayson=require(_0x6f50('0x7'));var client=jayson[_0x6f50('0x8')][_0x6f50('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x11bd7e,_0x35fdcb,_0x4c4d2c){return new BPromise(function(_0x1e9f69,_0x2443ca){return client['request'](_0x11bd7e,_0x4c4d2c)[_0x6f50('0xa')](function(_0x121d17){logger[_0x6f50('0xb')]('WhatsappQueueReport,\x20%s,\x20%s',_0x35fdcb,_0x6f50('0xc'));logger['debug'](_0x6f50('0xd'),_0x35fdcb,_0x6f50('0xc'),JSON[_0x6f50('0xe')](_0x121d17));if(_0x121d17[_0x6f50('0xf')]){if(_0x121d17[_0x6f50('0xf')][_0x6f50('0x10')]===0x1f4){logger[_0x6f50('0xf')](_0x6f50('0x11'),_0x35fdcb,_0x121d17[_0x6f50('0xf')][_0x6f50('0x12')]);return _0x2443ca(_0x121d17['error'][_0x6f50('0x12')]);}logger[_0x6f50('0xf')](_0x6f50('0x11'),_0x35fdcb,_0x121d17[_0x6f50('0xf')][_0x6f50('0x12')]);return _0x1e9f69(_0x121d17[_0x6f50('0xf')][_0x6f50('0x12')]);}else{logger['info'](_0x6f50('0x11'),_0x35fdcb,_0x6f50('0xc'));_0x1e9f69(_0x121d17[_0x6f50('0x13')][_0x6f50('0x12')]);}})[_0x6f50('0x14')](function(_0x522854){logger['error'](_0x6f50('0x11'),_0x35fdcb,_0x522854);_0x2443ca(_0x522854);});});}exports['CreateWhatsappQueueReport']=function(_0x34d997){var _0x1f99c1=this;return new Promise(function(_0x397a25,_0x3decd6){return db[_0x6f50('0x15')]['create'](_0x34d997[_0x6f50('0x16')],{'raw':_0x34d997['options']?_0x34d997[_0x6f50('0x17')][_0x6f50('0x18')]===undefined?!![]:![]:!![]})[_0x6f50('0xa')](function(_0x2c68be){logger[_0x6f50('0xb')]('CreateWhatsappQueueReport',_0x34d997);logger[_0x6f50('0x19')](_0x6f50('0x1a'),_0x34d997,JSON[_0x6f50('0xe')](_0x2c68be));_0x397a25(_0x2c68be);})[_0x6f50('0x14')](function(_0x1c24c8){logger['error'](_0x6f50('0x1a'),_0x1c24c8[_0x6f50('0x12')],_0x34d997);_0x3decd6(_0x1f99c1[_0x6f50('0xf')](0x1f4,_0x1c24c8['message']));});});};exports['UpdateWhatsappQueueReport']=function(_0x363a1c){var _0x37f0f2=this;return new Promise(function(_0x272c50,_0x10ba30){return db['WhatsappQueueReport'][_0x6f50('0x1b')](_0x363a1c[_0x6f50('0x16')],{'raw':_0x363a1c['options']?_0x363a1c['options'][_0x6f50('0x18')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x363a1c['options']?_0x363a1c[_0x6f50('0x17')][_0x6f50('0x1c')]||null:null,'attributes':_0x363a1c['options']?_0x363a1c[_0x6f50('0x17')][_0x6f50('0x1d')]||null:null,'limit':_0x363a1c[_0x6f50('0x17')]?_0x363a1c['options'][_0x6f50('0x1e')]||null:null})['then'](function(_0x1cbb12){logger[_0x6f50('0xb')]('UpdateWhatsappQueueReport',_0x363a1c);logger[_0x6f50('0x19')](_0x6f50('0x1f'),_0x363a1c,JSON['stringify'](_0x1cbb12));_0x272c50(_0x1cbb12);})['catch'](function(_0x460f4e){logger[_0x6f50('0xf')](_0x6f50('0x1f'),_0x460f4e['message'],_0x363a1c);_0x10ba30(_0x37f0f2[_0x6f50('0xf')](0x1f4,_0x460f4e['message']));});});};