Built motion from commit (unavailable).|2.4.18
[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 _0xaf3e=['debug','stringify','error','message','info','result','catch','lodash','util','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','Integration,\x20%s,\x20%s','request\x20sent'];(function(_0x440e50,_0x1313b2){var _0x33e75d=function(_0x13b482){while(--_0x13b482){_0x440e50['push'](_0x440e50['shift']());}};_0x33e75d(++_0x1313b2);}(_0xaf3e,0xcf));var _0xeaf3=function(_0x2e3107,_0x25f970){_0x2e3107=_0x2e3107-0x0;var _0x833d69=_0xaf3e[_0x2e3107];return _0x833d69;};'use strict';var _=require(_0xeaf3('0x0'));var util=require(_0xeaf3('0x1'));var moment=require('moment');var BPromise=require(_0xeaf3('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xeaf3('0x3'));var db=require(_0xeaf3('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xeaf3('0x5'))(_0xeaf3('0x6'));var config=require(_0xeaf3('0x7'));var jayson=require(_0xeaf3('0x8'));var client=jayson[_0xeaf3('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x33071f,_0x1725b7,_0xa51f56){return new BPromise(function(_0x120b24,_0x3d599a){return client[_0xeaf3('0xa')](_0x33071f,_0xa51f56)['then'](function(_0x3e666b){logger['info'](_0xeaf3('0xb'),_0x1725b7,_0xeaf3('0xc'));logger[_0xeaf3('0xd')]('Integration,\x20%s,\x20%s,\x20%s',_0x1725b7,_0xeaf3('0xc'),JSON[_0xeaf3('0xe')](_0x3e666b));if(_0x3e666b['error']){if(_0x3e666b[_0xeaf3('0xf')]['code']===0x1f4){logger[_0xeaf3('0xf')](_0xeaf3('0xb'),_0x1725b7,_0x3e666b[_0xeaf3('0xf')][_0xeaf3('0x10')]);return _0x3d599a(_0x3e666b['error'][_0xeaf3('0x10')]);}logger[_0xeaf3('0xf')](_0xeaf3('0xb'),_0x1725b7,_0x3e666b[_0xeaf3('0xf')]['message']);return _0x120b24(_0x3e666b[_0xeaf3('0xf')]['message']);}else{logger[_0xeaf3('0x11')]('Integration,\x20%s,\x20%s',_0x1725b7,'request\x20sent');_0x120b24(_0x3e666b[_0xeaf3('0x12')][_0xeaf3('0x10')]);}})[_0xeaf3('0x13')](function(_0x2aea53){logger[_0xeaf3('0xf')](_0xeaf3('0xb'),_0x1725b7,_0x2aea53);_0x3d599a(_0x2aea53);});});}