fae05e3d9a10741a09d9d5fee63119a540db00b5
[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 _0xe384=['info','request\x20sent','debug','Integration,\x20%s,\x20%s,\x20%s','stringify','error','code','Integration,\x20%s,\x20%s','message','catch','lodash','moment','bluebird','randomstring','../../config/utils','../../config/logger','jayson/promise','request'];(function(_0x8430f6,_0x109b16){var _0x5cf7d9=function(_0x5c1637){while(--_0x5c1637){_0x8430f6['push'](_0x8430f6['shift']());}};_0x5cf7d9(++_0x109b16);}(_0xe384,0x160));var _0x4e38=function(_0x31f2df,_0x34e634){_0x31f2df=_0x31f2df-0x0;var _0x1c543f=_0xe384[_0x31f2df];return _0x1c543f;};'use strict';var _=require(_0x4e38('0x0'));var util=require('util');var moment=require(_0x4e38('0x1'));var BPromise=require(_0x4e38('0x2'));var rs=require(_0x4e38('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x4e38('0x4'));var logger=require(_0x4e38('0x5'))('rpc');var config=require('../../config/environment');var jayson=require(_0x4e38('0x6'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x2a1873,_0x4d92b0,_0x582197){return new BPromise(function(_0x1030fd,_0x1a4795){return client[_0x4e38('0x7')](_0x2a1873,_0x582197)['then'](function(_0x488c9b){logger[_0x4e38('0x8')]('Integration,\x20%s,\x20%s',_0x4d92b0,_0x4e38('0x9'));logger[_0x4e38('0xa')](_0x4e38('0xb'),_0x4d92b0,_0x4e38('0x9'),JSON[_0x4e38('0xc')](_0x488c9b));if(_0x488c9b[_0x4e38('0xd')]){if(_0x488c9b['error'][_0x4e38('0xe')]===0x1f4){logger[_0x4e38('0xd')](_0x4e38('0xf'),_0x4d92b0,_0x488c9b['error'][_0x4e38('0x10')]);return _0x1a4795(_0x488c9b[_0x4e38('0xd')]['message']);}logger[_0x4e38('0xd')]('Integration,\x20%s,\x20%s',_0x4d92b0,_0x488c9b['error'][_0x4e38('0x10')]);return _0x1030fd(_0x488c9b[_0x4e38('0xd')]['message']);}else{logger[_0x4e38('0x8')](_0x4e38('0xf'),_0x4d92b0,_0x4e38('0x9'));_0x1030fd(_0x488c9b['result'][_0x4e38('0x10')]);}})[_0x4e38('0x11')](function(_0x2937be){logger[_0x4e38('0xd')](_0x4e38('0xf'),_0x4d92b0,_0x2937be);_0x1a4795(_0x2937be);});});}