e19d287d3b78d2c815525afebd8750061811ac75
[motion2.git] / server / api / integration / integration.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 _0x32f6=['../../mysqldb','../../config/utils','../../config/logger','rpc','request','then','info','request\x20sent','debug','error','Integration,\x20%s,\x20%s','message','result','moment','bluebird','ioredis'];(function(_0x432682,_0x253044){var _0x463d05=function(_0xa73403){while(--_0xa73403){_0x432682['push'](_0x432682['shift']());}};_0x463d05(++_0x253044);}(_0x32f6,0xbd));var _0x632f=function(_0xbf8ebe,_0x3b69a5){_0xbf8ebe=_0xbf8ebe-0x0;var _0x1e25e8=_0x32f6[_0xbf8ebe];return _0x1e25e8;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x632f('0x0'));var BPromise=require(_0x632f('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x632f('0x2'));var db=require(_0x632f('0x3'))['db'];var utils=require(_0x632f('0x4'));var logger=require(_0x632f('0x5'))(_0x632f('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x3a7a11,_0x2ce053,_0x3c7840){return new BPromise(function(_0x23a925,_0x3e3810){return client[_0x632f('0x7')](_0x3a7a11,_0x3c7840)[_0x632f('0x8')](function(_0x9e509e){logger[_0x632f('0x9')]('Integration,\x20%s,\x20%s',_0x2ce053,_0x632f('0xa'));logger[_0x632f('0xb')]('Integration,\x20%s,\x20%s,\x20%s',_0x2ce053,'request\x20sent',JSON['stringify'](_0x9e509e));if(_0x9e509e['error']){if(_0x9e509e[_0x632f('0xc')]['code']===0x1f4){logger[_0x632f('0xc')](_0x632f('0xd'),_0x2ce053,_0x9e509e[_0x632f('0xc')]['message']);return _0x3e3810(_0x9e509e['error']['message']);}logger['error']('Integration,\x20%s,\x20%s',_0x2ce053,_0x9e509e['error']['message']);return _0x23a925(_0x9e509e[_0x632f('0xc')][_0x632f('0xe')]);}else{logger['info'](_0x632f('0xd'),_0x2ce053,_0x632f('0xa'));_0x23a925(_0x9e509e[_0x632f('0xf')][_0x632f('0xe')]);}})['catch'](function(_0xa81024){logger[_0x632f('0xc')](_0x632f('0xd'),_0x2ce053,_0xa81024);_0x3e3810(_0xa81024);});});}