41fc8d3e991506363054f222d2e6c94ddf93b138
[motion2.git] / server / api / whatsappApplication / whatsappApplication.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 _0x44e8=['WhatsappApplication,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','WhatsappApplication,\x20%s,\x20%s','debug'];(function(_0x3759d1,_0x448438){var _0x4077c9=function(_0x10b820){while(--_0x10b820){_0x3759d1['push'](_0x3759d1['shift']());}};_0x4077c9(++_0x448438);}(_0x44e8,0xd7));var _0x844e=function(_0x16fb0e,_0x421512){_0x16fb0e=_0x16fb0e-0x0;var _0xa6e783=_0x44e8[_0x16fb0e];return _0xa6e783;};'use strict';var _=require(_0x844e('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x844e('0x1'));var rs=require(_0x844e('0x2'));var fs=require('fs');var Redis=require(_0x844e('0x3'));var db=require(_0x844e('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x844e('0x5'))(_0x844e('0x6'));var config=require(_0x844e('0x7'));var jayson=require(_0x844e('0x8'));var client=jayson['client'][_0x844e('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x238796,_0x1706b3,_0x11cbd6){return new BPromise(function(_0x571b91,_0x31ab50){return client[_0x844e('0xa')](_0x238796,_0x11cbd6)[_0x844e('0xb')](function(_0x134672){logger[_0x844e('0xc')](_0x844e('0xd'),_0x1706b3,'request\x20sent');logger[_0x844e('0xe')](_0x844e('0xf'),_0x1706b3,_0x844e('0x10'),JSON[_0x844e('0x11')](_0x134672));if(_0x134672[_0x844e('0x12')]){if(_0x134672[_0x844e('0x12')][_0x844e('0x13')]===0x1f4){logger['error'](_0x844e('0xd'),_0x1706b3,_0x134672[_0x844e('0x12')]['message']);return _0x31ab50(_0x134672[_0x844e('0x12')][_0x844e('0x14')]);}logger['error'](_0x844e('0xd'),_0x1706b3,_0x134672[_0x844e('0x12')][_0x844e('0x14')]);return _0x571b91(_0x134672['error'][_0x844e('0x14')]);}else{logger[_0x844e('0xc')](_0x844e('0xd'),_0x1706b3,_0x844e('0x10'));_0x571b91(_0x134672[_0x844e('0x15')][_0x844e('0x14')]);}})[_0x844e('0x16')](function(_0x5506ef){logger['error'](_0x844e('0xd'),_0x1706b3,_0x5506ef);_0x31ab50(_0x5506ef);});});}