106e0d2e274d513966bb357fae80689794357df9
[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 _0xbcc7=['../../config/logger','rpc','jayson/promise','client','http','then','Integration,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','lodash','util','bluebird','../../mysqldb'];(function(_0x12a617,_0x3b7d72){var _0x59afb0=function(_0x34e681){while(--_0x34e681){_0x12a617['push'](_0x12a617['shift']());}};_0x59afb0(++_0x3b7d72);}(_0xbcc7,0x19a));var _0x7bcc=function(_0xb76b10,_0x4bdd6c){_0xb76b10=_0xb76b10-0x0;var _0x277068=_0xbcc7[_0xb76b10];return _0x277068;};'use strict';var _=require(_0x7bcc('0x0'));var util=require(_0x7bcc('0x1'));var moment=require('moment');var BPromise=require(_0x7bcc('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x7bcc('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x7bcc('0x4'))(_0x7bcc('0x5'));var config=require('../../config/environment');var jayson=require(_0x7bcc('0x6'));var client=jayson[_0x7bcc('0x7')][_0x7bcc('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2f1cb3,_0x127f68,_0x33ea35){return new BPromise(function(_0x5534d5,_0x18939b){return client['request'](_0x2f1cb3,_0x33ea35)[_0x7bcc('0x9')](function(_0x3524cc){logger['info'](_0x7bcc('0xa'),_0x127f68,'request\x20sent');logger['debug']('Integration,\x20%s,\x20%s,\x20%s',_0x127f68,_0x7bcc('0xb'),JSON[_0x7bcc('0xc')](_0x3524cc));if(_0x3524cc[_0x7bcc('0xd')]){if(_0x3524cc[_0x7bcc('0xd')][_0x7bcc('0xe')]===0x1f4){logger[_0x7bcc('0xd')](_0x7bcc('0xa'),_0x127f68,_0x3524cc['error'][_0x7bcc('0xf')]);return _0x18939b(_0x3524cc[_0x7bcc('0xd')][_0x7bcc('0xf')]);}logger[_0x7bcc('0xd')](_0x7bcc('0xa'),_0x127f68,_0x3524cc[_0x7bcc('0xd')]['message']);return _0x5534d5(_0x3524cc[_0x7bcc('0xd')][_0x7bcc('0xf')]);}else{logger[_0x7bcc('0x10')](_0x7bcc('0xa'),_0x127f68,_0x7bcc('0xb'));_0x5534d5(_0x3524cc[_0x7bcc('0x11')][_0x7bcc('0xf')]);}})['catch'](function(_0x20105e){logger['error'](_0x7bcc('0xa'),_0x127f68,_0x20105e);_0x18939b(_0x20105e);});});}