|
@ -22,44 +22,71 @@ function getHashCode(req) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const createLiquiloanInvestor = async (req, res) => { |
|
|
|
|
|
|
|
|
|
|
|
var promiseArray = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const createLiquiloanInvestor = () => { |
|
|
for (let i = 0; i < arrayGetList.length; i++) { |
|
|
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) |
|
|
|
|
|
|
|
|
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) { |
|
|
|
|
|
if (error) throw new Error(error); |
|
|
|
|
|
getUrlAndStore(response.body) |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
console.log(await Promise.all(promiseArray)); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
const getUrlAndStore = async (body) => { |
|
|
|
|
|
try { |
|
|
|
|
|
const data = JSON.parse(body) |
|
|
|
|
|
console.log(data, "KDDODKOKODODKDKO"); |
|
|
|
|
|
let callsData = data.data; |
|
|
|
|
|
let calls = []; |
|
|
|
|
|
// if (callsData.length) {
|
|
|
|
|
|
// for (let i = 0; i < callsData.length; i++) {
|
|
|
|
|
|
// let record = {};
|
|
|
|
|
|
// record.sid = callsData[i].Sid;
|
|
|
|
|
|
// record.date_created = callsData[i].DateCreated;
|
|
|
|
|
|
// record.date_updated = callsData[i].DateUpdated;
|
|
|
|
|
|
// record.account_sid = callsData[i].AccountSid;
|
|
|
|
|
|
// record.to = callsData[i].To;
|
|
|
|
|
|
// record.from = callsData[i].From;
|
|
|
|
|
|
// record.phone_number = callsData[i].PhoneNumber;
|
|
|
|
|
|
// record.phone_number_sid = callsData[i].PhoneNumberSid;
|
|
|
|
|
|
// record.status = callsData[i].Status;
|
|
|
|
|
|
// record.start_time = callsData[i].StartTime;
|
|
|
|
|
|
// record.end_time = callsData[i].EndTime;
|
|
|
|
|
|
// record.duration = callsData[i].Duration;
|
|
|
|
|
|
// record.price = callsData[i].Price;
|
|
|
|
|
|
// record.direction = callsData[i].Direction;
|
|
|
|
|
|
// record.recording_url = callsData[i].RecordingUrl;
|
|
|
|
|
|
|
|
|
|
|
|
// record.conversation_duration = callsData[i].Details.ConversationDuration;
|
|
|
|
|
|
// record.leg1_status = callsData[i].Details.Leg1Status;
|
|
|
|
|
|
// record.leg2_status = callsData[i].Details.Leg2Status;
|
|
|
|
|
|
// record.created_at = new Date();
|
|
|
|
|
|
|
|
|
// const createLiquiloanInvestor = (req, res) => {
|
|
|
|
|
|
// for (let i = 0; i < arrayGetList.length; i++) {
|
|
|
|
|
|
// const element = arrayGetList[i];
|
|
|
|
|
|
// main(element, element.length)
|
|
|
|
|
|
// }
|
|
|
|
|
|
// res.se
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// calls.push(record);
|
|
|
|
|
|
// console.log('calls---->', calls.length);
|
|
|
|
|
|
// await db.exotelCalls.bulkCreate(calls);
|
|
|
|
|
|
// }
|
|
|
|
|
|
} |
|
|
|
|
|
catch (err) { |
|
|
|
|
|
console.log(err); |
|
|
|
|
|
winstonLogger.error('getUrlAndStore() error is : ' + err); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
createLiquiloanInvestor |
|
|
createLiquiloanInvestor |
|
|