|
|
@ -0,0 +1,67 @@ |
|
|
|
'use strict' |
|
|
|
|
|
|
|
const request = require("request"); |
|
|
|
const constants = require('../utils/consts'); |
|
|
|
const db = require('../utils/db_config'); |
|
|
|
const crypto = require('crypto'); |
|
|
|
const { getCurrentDateTime } = require("./helper"); |
|
|
|
|
|
|
|
function generateHMACSHA256(input, key) { |
|
|
|
const hmac = crypto.createHmac('sha256', key); |
|
|
|
hmac.update(input, 'utf8'); // Ensure input encoding matches C# (UTF-8)
|
|
|
|
return hmac.digest('hex'); |
|
|
|
} |
|
|
|
let arrayGetList = ["2509295", "2509", "2820644", "437290"] |
|
|
|
function getHashCode(req) { |
|
|
|
// console.log(`368907||${getCurrentDateTime()}`, "DKDDODKOODDOK");
|
|
|
|
const inputString_GetInvestorDashboard = `${req}||${getCurrentDateTime()}`; |
|
|
|
const key = "27E6A91CEE689"; |
|
|
|
|
|
|
|
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key); |
|
|
|
return hash_GetInvestorDashboard |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const createLiquiloanInvestor = async (req, res) => { |
|
|
|
|
|
|
|
var promiseArray = []; |
|
|
|
|
|
|
|
for (let i = 0; i < arrayGetList.length; i++) { |
|
|
|
promiseArray.push(new Promise((resolve, reject) => { |
|
|
|
var options = { |
|
|
|
method: 'POST', |
|
|
|
url: 'https://supply-integration.liquiloans.com/api/v2/GetInvestmentSummary', |
|
|
|
headers: { |
|
|
|
'Content-Type': 'application/json', |
|
|
|
'Cookie': 'AWSALB=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW; AWSALBCORS=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW' |
|
|
|
}, |
|
|
|
body: JSON.stringify({ |
|
|
|
"investor_id": arrayGetList[i], |
|
|
|
"timestamp": getCurrentDateTime(), |
|
|
|
"checksum": getHashCode(arrayGetList[i]), |
|
|
|
"mid": "M00201" |
|
|
|
}) |
|
|
|
|
|
|
|
}; |
|
|
|
request(options, function (error, response, body) { |
|
|
|
if (error) reject(error); |
|
|
|
else resolve(body) |
|
|
|
}) |
|
|
|
})) |
|
|
|
} |
|
|
|
console.log(await Promise.all(promiseArray)); |
|
|
|
} |
|
|
|
|
|
|
|
// const createLiquiloanInvestor = (req, res) => {
|
|
|
|
// for (let i = 0; i < arrayGetList.length; i++) {
|
|
|
|
// const element = arrayGetList[i];
|
|
|
|
// main(element, element.length)
|
|
|
|
// }
|
|
|
|
// res.se
|
|
|
|
// }
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
createLiquiloanInvestor |
|
|
|
} |
|
|
|
|