4ac5cbdf439dff2aebd884c589b4a8bc3c78cf73
[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 _0x5a96=['debug','Integration,\x20%s,\x20%s,\x20%s','error','code','Integration,\x20%s,\x20%s','message','result','catch','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','then','info','request\x20sent'];(function(_0x36c5b0,_0x5001da){var _0xf19333=function(_0x1e880a){while(--_0x1e880a){_0x36c5b0['push'](_0x36c5b0['shift']());}};_0xf19333(++_0x5001da);}(_0x5a96,0xbc));var _0x65a9=function(_0x7f650c,_0x16a2e7){_0x7f650c=_0x7f650c-0x0;var _0x246d82=_0x5a96[_0x7f650c];return _0x246d82;};'use strict';var _=require(_0x65a9('0x0'));var util=require(_0x65a9('0x1'));var moment=require('moment');var BPromise=require(_0x65a9('0x2'));var rs=require(_0x65a9('0x3'));var fs=require('fs');var Redis=require(_0x65a9('0x4'));var db=require(_0x65a9('0x5'))['db'];var utils=require(_0x65a9('0x6'));var logger=require(_0x65a9('0x7'))('rpc');var config=require(_0x65a9('0x8'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x596d73,_0x94fce1,_0x107fea){return new BPromise(function(_0x5ae332,_0x3330b9){return client['request'](_0x596d73,_0x107fea)[_0x65a9('0x9')](function(_0x3d6166){logger[_0x65a9('0xa')]('Integration,\x20%s,\x20%s',_0x94fce1,_0x65a9('0xb'));logger[_0x65a9('0xc')](_0x65a9('0xd'),_0x94fce1,_0x65a9('0xb'),JSON['stringify'](_0x3d6166));if(_0x3d6166[_0x65a9('0xe')]){if(_0x3d6166['error'][_0x65a9('0xf')]===0x1f4){logger[_0x65a9('0xe')](_0x65a9('0x10'),_0x94fce1,_0x3d6166['error']['message']);return _0x3330b9(_0x3d6166[_0x65a9('0xe')][_0x65a9('0x11')]);}logger['error']('Integration,\x20%s,\x20%s',_0x94fce1,_0x3d6166[_0x65a9('0xe')][_0x65a9('0x11')]);return _0x5ae332(_0x3d6166[_0x65a9('0xe')][_0x65a9('0x11')]);}else{logger[_0x65a9('0xa')]('Integration,\x20%s,\x20%s',_0x94fce1,'request\x20sent');_0x5ae332(_0x3d6166[_0x65a9('0x12')][_0x65a9('0x11')]);}})[_0x65a9('0x13')](function(_0x131414){logger[_0x65a9('0xe')](_0x65a9('0x10'),_0x94fce1,_0x131414);_0x3330b9(_0x131414);});});}