inquiry-to-komodo.js
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const MODULE_NAME = 'ACTIONS.INQUIRY-TO-KOMODO';
const logger = require('tektrans-logger');
const axios = require('axios').default;
const config = require('../config');
const client = axios.create({
baseURL: config.komodo_http_get_x.url,
timeout: config.komodo_http_get_x.request_timeout_ms,
});
/**
* request inquiry transaction to komodo
*
* @param {string} xid
* @param {string} requestId
* @param {string} destination
* @param {string} productName
* @param {string} reverseUrl
*/
module.exports = async (
xid,
requestId,
destination,
productName,
reverseUrl,
) => {
logger.verbose(`${MODULE_NAME} 4AD4DF41: request inquiry to komodo`, {
requestId, destination, productName, reverseUrl, xid,
});
const params = {
request_id: requestId,
terminal_name: config.komodo_http_get_x.terminal_name,
password: config.komodo_http_get_x.password,
destination,
product_name: productName,
reverse_url: reverseUrl,
};
try {
const response = await client.get('/inquiry', {
params,
});
if (!response) {
throw new Error(`${MODULE_NAME} 6CE3E06E: Empty response from komodo`);
}
if (!response.data) {
throw new Error(`${MODULE_NAME} F236476F: Empty response data from komodo`);
}
return response.data;
} catch (err) {
logger.warn(`${MODULE_NAME} 48BAA6B7: Exception`, {
xid,
requestId,
destination,
productName,
message: err.message,
});
throw err;
}
};