Built motion from commit (unavailable).|2.5.23
[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 _0x40c2=['request','info','Integration,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x3c4099,_0x36e292){var _0x3487ae=function(_0x44a42e){while(--_0x44a42e){_0x3c4099['push'](_0x3c4099['shift']());}};_0x3487ae(++_0x36e292);}(_0x40c2,0x10d));var _0x240c=function(_0xb2ce63,_0x2ebf5e){_0xb2ce63=_0xb2ce63-0x0;var _0x164639=_0x40c2[_0xb2ce63];return _0x164639;};'use strict';var _=require('lodash');var util=require(_0x240c('0x0'));var moment=require(_0x240c('0x1'));var BPromise=require(_0x240c('0x2'));var rs=require(_0x240c('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x240c('0x4'));var logger=require(_0x240c('0x5'))(_0x240c('0x6'));var config=require(_0x240c('0x7'));var jayson=require(_0x240c('0x8'));var client=jayson[_0x240c('0x9')][_0x240c('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x593b3f,_0x1d3dbf,_0x3f1d10){return new BPromise(function(_0x316210,_0x428465){return client[_0x240c('0xb')](_0x593b3f,_0x3f1d10)['then'](function(_0x58ec77){logger[_0x240c('0xc')](_0x240c('0xd'),_0x1d3dbf,'request\x20sent');logger['debug']('Integration,\x20%s,\x20%s,\x20%s',_0x1d3dbf,_0x240c('0xe'),JSON[_0x240c('0xf')](_0x58ec77));if(_0x58ec77[_0x240c('0x10')]){if(_0x58ec77[_0x240c('0x10')]['code']===0x1f4){logger['error'](_0x240c('0xd'),_0x1d3dbf,_0x58ec77['error']['message']);return _0x428465(_0x58ec77[_0x240c('0x10')][_0x240c('0x11')]);}logger[_0x240c('0x10')](_0x240c('0xd'),_0x1d3dbf,_0x58ec77[_0x240c('0x10')][_0x240c('0x11')]);return _0x316210(_0x58ec77['error'][_0x240c('0x11')]);}else{logger[_0x240c('0xc')](_0x240c('0xd'),_0x1d3dbf,_0x240c('0xe'));_0x316210(_0x58ec77[_0x240c('0x12')][_0x240c('0x11')]);}})[_0x240c('0x13')](function(_0x3d2251){logger[_0x240c('0x10')](_0x240c('0xd'),_0x1d3dbf,_0x3d2251);_0x428465(_0x3d2251);});});}