Add lambda scrub functionality and remove vehicle lookup.

This commit is contained in:
Patrick Fic
2026-01-08 15:21:39 -08:00
parent 2a53f7b7d0
commit 1650a9b6f9
17 changed files with 3534 additions and 67 deletions

View File

@@ -1,10 +1,7 @@
import dayjs from "dayjs";
import _ from "lodash";
import { RawJobDataObject } from "../decoder/decoder";
import { ESJobObject } from "./es-job-object.interface";
import _ from "lodash";
import dayjas from "dayjs";
import dayjs from "dayjs";
import axios from "axios";
const sendingEntityId = "87330f61-412b-4251-baaa-d026565b23c5";
async function TransformJobForEstimateScrubber(
job: RawJobDataObject,
@@ -194,11 +191,11 @@ async function TransformJobForEstimateScrubber(
//Add the ES Objects.
const vehType: string = (
await axios.post(`https://api.test.imex.online/es/vehicletype`, {
model: job.v_model_desc,
})
).data?.type;
// const vehType: string = (
// await axios.post(`https://api.test.imex.online/es/vehicletype`, {
// model: job.v_model_desc,
// })
// ).data?.type;
return {
//TODO: Remove hard coded values
@@ -207,12 +204,12 @@ async function TransformJobForEstimateScrubber(
impact_2: job.area_of_damage?.impact2,
close_date: null,
created_at: dayjs().toISOString(),
id: "c478593b-58a2-4bab-b7c7-2df19a257b2b",
id: "00000000-0000-0000-0000-000000000000", //Placeholder ID
// group: "Group 10",
// group_verified: false,
updated_at: dayjs().toISOString(),
v_age: 20, //Needed? RPS calc.
v_type: "PC", // need to get from API.
v_age: -1, //Needed? RPS calc.
v_type: "TBD", // need to get from API.
v_makedesc: job.v_make_desc,
v_model: job.v_model_desc,
rates,
@@ -221,13 +218,13 @@ async function TransformJobForEstimateScrubber(
ro_number: null,
requires_reimport: false,
v_mileage: job.kmin?.toString() || "",
sending_entity_id: sendingEntityId,
sending_entity_id: "",
sending_entity_accept_terms_of_use: true,
association_switch: "ATAM", //TODO: This needs to be updated ,
rf_ph1: "2043792253", //TODO - is this needed anymore?
rf_zip: "R0G 1Z0", //TODO - is this needed anymore?
g_ttl_amt: job.clm_total,
source_system: job.est_system || "M", //TODO - pull this.
source_system: job.est_system || "M",
joblines: job.joblines?.data?.map((line) => ({
..._.omit(line, [
"lbr_tax",

View File

@@ -48,19 +48,23 @@ async function ScrubEstimate({
//Scrub Estimate Transformer. Original schema kept to keep data in line with ImEX standards.
const transformedJob = await TransformJobForEstimateScrubber(job);
const basicAuthUser = "Imex2";
const basicAuthpassword = "Patrick";
const currentChannel = autoUpdater.channel;
let estimateScrubberUrl: string;
switch (currentChannel) {
case null:
case "dev":
estimateScrubberUrl = "https://dev.es.imex.online/scrub"; //dev specific URL.
break;
case "alpha":
estimateScrubberUrl = "https://4284-79287.el-alt.com"; //dev specific URL.
estimateScrubberUrl = "https://alpha.es.imex.online/scrub"; //dev specific URL.
break;
case "beta":
estimateScrubberUrl = "https://4284-79073.el-alt.com"; //Beta specific URL.
estimateScrubberUrl = "https://beta.es.imex.online/scrub"; //Beta specific URL.
break;
case "latest":
default:
estimateScrubberUrl = "https://insurtechtoolkit.com"; //Production route.
estimateScrubberUrl = "https://es.imex.online/scrub"; //Production route.
break;
}
@@ -84,30 +88,14 @@ async function ScrubEstimate({
// Continue with the rest of the function even if this fails
}
const formData = new FormData();
const jsonString = JSON.stringify(transformedJob);
formData.append(
"file",
new Blob([jsonString], { type: "application/json" }),
`${fileName}.json`,
);
const result = await axios.post(estimateScrubberUrl, {
esApiKey,
estimate: transformedJob,
fileName,
});
const result = await axios.post(
`${estimateScrubberUrl}/api/sendems`,
formData,
{
auth: {
username: basicAuthUser,
password: basicAuthpassword,
},
headers: {
APIkey: esApiKey,
},
},
);
const { resultPDFUrl, reportIssueUrl } = result?.data ?? {};
const resultPDFUrl = result?.data?.report_link;
const reportIssueUrl = `https://insurtechtoolkit.com/pcontactUs.aspx?apiKey=${esApiKey}&file=${fileName}.json`;
// log.log("Estimate Scrubber Result:", result.data, resultPDFUrl);
// const b = BrowserWindow.getAllWindows()[0];
// b.webContents.send(ipcTypes.app.toRenderer.scrubResults, {