Built motion from commit (unavailable).|2.4.3
[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 _0x0234=['rpc','../../config/environment','jayson/promise','client','http','then','info','Integration,\x20%s,\x20%s','request\x20sent','Integration,\x20%s,\x20%s,\x20%s','error','code','message','result','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger'];(function(_0x1e8242,_0x31e119){var _0x40856a=function(_0x58f74c){while(--_0x58f74c){_0x1e8242['push'](_0x1e8242['shift']());}};_0x40856a(++_0x31e119);}(_0x0234,0xea));var _0x4023=function(_0x519af2,_0x1043e9){_0x519af2=_0x519af2-0x0;var _0x3743b8=_0x0234[_0x519af2];return _0x3743b8;};'use strict';var _=require(_0x4023('0x0'));var util=require(_0x4023('0x1'));var moment=require(_0x4023('0x2'));var BPromise=require(_0x4023('0x3'));var rs=require(_0x4023('0x4'));var fs=require('fs');var Redis=require(_0x4023('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x4023('0x6'));var logger=require(_0x4023('0x7'))(_0x4023('0x8'));var config=require(_0x4023('0x9'));var jayson=require(_0x4023('0xa'));var client=jayson[_0x4023('0xb')][_0x4023('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x2a5811,_0x578e93,_0x4e2bbc){return new BPromise(function(_0x19ab21,_0x44458f){return client['request'](_0x2a5811,_0x4e2bbc)[_0x4023('0xd')](function(_0x4111cd){logger[_0x4023('0xe')](_0x4023('0xf'),_0x578e93,_0x4023('0x10'));logger['debug'](_0x4023('0x11'),_0x578e93,_0x4023('0x10'),JSON['stringify'](_0x4111cd));if(_0x4111cd[_0x4023('0x12')]){if(_0x4111cd[_0x4023('0x12')][_0x4023('0x13')]===0x1f4){logger['error']('Integration,\x20%s,\x20%s',_0x578e93,_0x4111cd['error']['message']);return _0x44458f(_0x4111cd['error'][_0x4023('0x14')]);}logger['error'](_0x4023('0xf'),_0x578e93,_0x4111cd[_0x4023('0x12')][_0x4023('0x14')]);return _0x19ab21(_0x4111cd[_0x4023('0x12')]['message']);}else{logger[_0x4023('0xe')](_0x4023('0xf'),_0x578e93,_0x4023('0x10'));_0x19ab21(_0x4111cd[_0x4023('0x15')][_0x4023('0x14')]);}})['catch'](function(_0x12df10){logger['error'](_0x4023('0xf'),_0x578e93,_0x12df10);_0x44458f(_0x12df10);});});}