Built motion from commit (unavailable).|2.5.11
[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 _0x649b=['../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','then','info','request\x20sent','debug','Integration,\x20%s,\x20%s,\x20%s','error','Integration,\x20%s,\x20%s','message','catch','moment','bluebird'];(function(_0x6b5c51,_0x1ba06e){var _0xd0b75b=function(_0x3c2859){while(--_0x3c2859){_0x6b5c51['push'](_0x6b5c51['shift']());}};_0xd0b75b(++_0x1ba06e);}(_0x649b,0x166));var _0xb649=function(_0x20d6b8,_0x16c21f){_0x20d6b8=_0x20d6b8-0x0;var _0x5abd12=_0x649b[_0x20d6b8];return _0x5abd12;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xb649('0x0'));var BPromise=require(_0xb649('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb649('0x2'))['db'];var utils=require('../../config/utils');var logger=require(_0xb649('0x3'))(_0xb649('0x4'));var config=require(_0xb649('0x5'));var jayson=require('jayson/promise');var client=jayson[_0xb649('0x6')][_0xb649('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x407bdb,_0x5c0b1c,_0x539d84){return new BPromise(function(_0x4227a6,_0x4c5c97){return client[_0xb649('0x8')](_0x407bdb,_0x539d84)[_0xb649('0x9')](function(_0x2d4886){logger[_0xb649('0xa')]('Integration,\x20%s,\x20%s',_0x5c0b1c,_0xb649('0xb'));logger[_0xb649('0xc')](_0xb649('0xd'),_0x5c0b1c,_0xb649('0xb'),JSON['stringify'](_0x2d4886));if(_0x2d4886[_0xb649('0xe')]){if(_0x2d4886['error']['code']===0x1f4){logger['error'](_0xb649('0xf'),_0x5c0b1c,_0x2d4886[_0xb649('0xe')][_0xb649('0x10')]);return _0x4c5c97(_0x2d4886[_0xb649('0xe')]['message']);}logger[_0xb649('0xe')](_0xb649('0xf'),_0x5c0b1c,_0x2d4886[_0xb649('0xe')]['message']);return _0x4227a6(_0x2d4886[_0xb649('0xe')][_0xb649('0x10')]);}else{logger[_0xb649('0xa')](_0xb649('0xf'),_0x5c0b1c,_0xb649('0xb'));_0x4227a6(_0x2d4886['result'][_0xb649('0x10')]);}})[_0xb649('0x11')](function(_0x11e3c9){logger['error'](_0xb649('0xf'),_0x5c0b1c,_0x11e3c9);_0x4c5c97(_0x11e3c9);});});}