ES Schema changes & initial upload attempt.
This commit is contained in:
@@ -10,20 +10,34 @@ const { BrowserWindow } = require("electron");
|
||||
|
||||
|
||||
async function ScrubEstimate({ job }) {
|
||||
//These need to be removed.
|
||||
//TODO: Fetch these from ImEX Online API.
|
||||
const basicAuthUser = "Imex";
|
||||
const basicAuthpassword = "Patrick";
|
||||
const estimateScrubberUrl = "https://insurtechtoolkit.com/api/sendems";
|
||||
const sendingEntityId = '87330f61-412b-4251-baaa-d026565b23c5'
|
||||
|
||||
//Perform data manipulation on the job object
|
||||
if (!job) {
|
||||
console.error("No job provided to ScrubEstimate");
|
||||
return;
|
||||
}
|
||||
|
||||
//Set shop metrics
|
||||
job.sending_entity_id = sendingEntityId;
|
||||
job.sending_entity_accept_terms_of_use = true;
|
||||
job.association_switch = "ATAM";
|
||||
job.rf_ph1 = "R0G 1Z0";
|
||||
job.rf_zip = "2043792253";
|
||||
job.g_ttl_amt = job.clm_total;
|
||||
|
||||
|
||||
const fileName = `RPSTest-${job.id}-${Date.now()}`;
|
||||
console.log("*** ~ ScrubEstimate ~ job:", job);
|
||||
|
||||
//Build the JSON Form Data
|
||||
const fileName = `RPSTest-${job.id}-${Date.now()}`;
|
||||
const formData = new FormData();
|
||||
const jsonString = JSON.stringify(job);
|
||||
formData.append("file", new Blob([jsonString], { type: "application/json" }), `${fileName}.json`);
|
||||
|
||||
console.log("*** ~ ScrubEstimate ~ formData.getHeaders();:", formData);
|
||||
const result = await axios.post(estimateScrubberUrl, formData, {
|
||||
auth: {
|
||||
username: basicAuthUser,
|
||||
@@ -33,7 +47,7 @@ async function ScrubEstimate({ job }) {
|
||||
});
|
||||
console.log("*** ~ handleScrub ~ result:", result.data);
|
||||
|
||||
const resultPDFUrl = `https://www.insurtechtoolkit.com/analysis/${fileName}.pdf`;
|
||||
const resultPDFUrl = result?.data?.[0] || `https://www.insurtechtoolkit.com/analysis/${fileName}.pdf`;
|
||||
|
||||
console.log("*** ~ handleScrub ~ resultPDFUrl:", resultPDFUrl);
|
||||
const pdfWindow = new BrowserWindow({
|
||||
|
||||
Reference in New Issue
Block a user