feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration -Dedupe

This commit is contained in:
Dave
2025-11-07 16:09:18 -05:00
parent c0157454e1
commit d45d557a81
2 changed files with 32 additions and 48 deletions

View File

@@ -160,36 +160,8 @@ async function rrGetAdvisors(bodyshop, args = {}) {
return res?.data ?? res;
}
/**
* Parts lookup (graceful if the underlying lib exposes a different name)
* @param bodyshop
* @param args - common fields like { partNumber, description, make, model, year }
*/
async function rrGetParts(bodyshop, args = {}) {
const { client, opts } = buildClientAndOpts(bodyshop);
const payload = {
partNumber: args.partNumber ?? args.partNo ?? args.number ?? undefined,
description: args.description ?? undefined,
make: args.make ?? undefined,
model: args.model ?? undefined,
year: args.year ?? undefined
};
// Try common method names. If none exist, return an empty list to avoid crashes.
if (typeof client.getParts === "function") {
const res = await client.getParts(payload, opts);
return res?.data ?? res;
}
if (typeof client.getPartNumbers === "function") {
const res = await client.getPartNumbers(payload, opts);
return res?.data ?? res;
}
return [];
}
module.exports = {
rrCombinedSearch,
rrGetAdvisors,
rrGetParts,
buildClientAndOpts
};