second commit
This commit is contained in:
25
src/controllers/customer_details.controller.js
Normal file
25
src/controllers/customer_details.controller.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const axios = require('axios');
|
||||
const { logger } = require('../util/logger');
|
||||
|
||||
async function getDetails(customerNo) {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
'http://localhost:8686/kccb/cbs/custInfo/details',
|
||||
{ params: { stcustno: customerNo } }
|
||||
);
|
||||
const details = response.data;
|
||||
logger.info(details, 'response from cbs');
|
||||
const processedDetails = details.map((acc) => ({
|
||||
...acc,
|
||||
activeAccounts: details.length,
|
||||
cifNumber: customerNo,
|
||||
}));
|
||||
return processedDetails;
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
'API call failed: ' + (error.response?.data?.message || error.message)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { getDetails };
|
||||
Reference in New Issue
Block a user