feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Checkpoint - Remove old attempt at Reynolds Integration in favor of new library.

This commit is contained in:
Dave
2025-10-29 10:42:32 -04:00
parent 319f3220ed
commit e06f0f9918
36 changed files with 2468 additions and 3736 deletions

View File

@@ -0,0 +1,32 @@
const { getRRConfigForBodyshop } = require("./rr-config");
const { RrApiError } = require("./rr-error");
/**
* Extracts bodyshopId from body, job, or header and loads RR config.
* @returns {Promise<{ bodyshopId: string, config: any }>}
*/
async function resolveRRConfigHttp(req) {
const body = req?.body || {};
const fromBody = body.bodyshopId;
const fromJob = body.job && (body.job.shopid || body.job.bodyshopId);
const fromHeader = typeof req.get === "function" ? req.get("x-bodyshop-id") : undefined;
const bodyshopId = fromBody || fromJob || fromHeader;
if (!bodyshopId) {
throw new RrApiError(
"Missing bodyshopId (expected in body.bodyshopId, body.job.shopid/bodyshopId, or x-bodyshop-id header)",
"BAD_REQUEST"
);
}
const config = await getRRConfigForBodyshop(bodyshopId);
if (!config?.dealerNumber) {
throw new RrApiError(`RR config not found for bodyshopId=${bodyshopId} (missing dealerNumber)`, "NOT_CONFIGURED");
}
return { bodyshopId, config };
}
module.exports = { resolveRRConfigHttp };