1a16182620621cfc7f17d2e15d32a38d2784d0ff
[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 _0x8e6c=['stringify','error','code','message','catch','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','then','info','Integration,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x211fb5,_0x52efb0){var _0x221845=function(_0x3a29a0){while(--_0x3a29a0){_0x211fb5['push'](_0x211fb5['shift']());}};_0x221845(++_0x52efb0);}(_0x8e6c,0x7d));var _0xc8e6=function(_0x425b1d,_0x1407f9){_0x425b1d=_0x425b1d-0x0;var _0x16233b=_0x8e6c[_0x425b1d];return _0x16233b;};'use strict';var _=require(_0xc8e6('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xc8e6('0x1'));var rs=require(_0xc8e6('0x2'));var fs=require('fs');var Redis=require(_0xc8e6('0x3'));var db=require(_0xc8e6('0x4'))['db'];var utils=require(_0xc8e6('0x5'));var logger=require('../../config/logger')(_0xc8e6('0x6'));var config=require(_0xc8e6('0x7'));var jayson=require(_0xc8e6('0x8'));var client=jayson['client'][_0xc8e6('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1b3e67,_0x28a0cf,_0x21f450){return new BPromise(function(_0x5b870a,_0x36c676){return client['request'](_0x1b3e67,_0x21f450)[_0xc8e6('0xa')](function(_0x801df5){logger[_0xc8e6('0xb')](_0xc8e6('0xc'),_0x28a0cf,_0xc8e6('0xd'));logger[_0xc8e6('0xe')]('Integration,\x20%s,\x20%s,\x20%s',_0x28a0cf,_0xc8e6('0xd'),JSON[_0xc8e6('0xf')](_0x801df5));if(_0x801df5[_0xc8e6('0x10')]){if(_0x801df5['error'][_0xc8e6('0x11')]===0x1f4){logger[_0xc8e6('0x10')]('Integration,\x20%s,\x20%s',_0x28a0cf,_0x801df5[_0xc8e6('0x10')]['message']);return _0x36c676(_0x801df5[_0xc8e6('0x10')][_0xc8e6('0x12')]);}logger[_0xc8e6('0x10')]('Integration,\x20%s,\x20%s',_0x28a0cf,_0x801df5['error'][_0xc8e6('0x12')]);return _0x5b870a(_0x801df5[_0xc8e6('0x10')][_0xc8e6('0x12')]);}else{logger[_0xc8e6('0xb')](_0xc8e6('0xc'),_0x28a0cf,_0xc8e6('0xd'));_0x5b870a(_0x801df5['result'][_0xc8e6('0x12')]);}})[_0xc8e6('0x13')](function(_0x4c2c93){logger[_0xc8e6('0x10')](_0xc8e6('0xc'),_0x28a0cf,_0x4c2c93);_0x36c676(_0x4c2c93);});});}