feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Checkpoint
This commit is contained in:
@@ -13,14 +13,12 @@ function buildClientAndOpts(bodyshop) {
|
||||
password: cfg.password,
|
||||
timeoutMs: cfg.timeoutMs,
|
||||
retries: cfg.retries
|
||||
// optional debug logger already inside lib; leave defaults
|
||||
});
|
||||
|
||||
// Common CallOptions for all ops; routing is CRITICAL for Destination block
|
||||
const opts = {
|
||||
routing: cfg.routing,
|
||||
envelope: {
|
||||
// You can override these per-call if needed
|
||||
sender: {
|
||||
component: "Rome",
|
||||
task: "CVC",
|
||||
@@ -28,7 +26,6 @@ function buildClientAndOpts(bodyshop) {
|
||||
creator: "RCI",
|
||||
senderName: "RCI"
|
||||
}
|
||||
// bodId/creationDateTime auto-filled by the client if omitted
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,7 +52,9 @@ function toCombinedSearchPayload(args = {}) {
|
||||
}
|
||||
|
||||
const payload = {
|
||||
maxResults: q.maxResults || q.maxRecs || 50,
|
||||
// set both; the XML layer renders MaxRecs
|
||||
maxRecs: q.maxResults ?? q.maxRecs ?? 50,
|
||||
maxResults: q.maxResults ?? q.maxRecs ?? 50,
|
||||
kind
|
||||
};
|
||||
|
||||
@@ -74,6 +73,7 @@ function toCombinedSearchPayload(args = {}) {
|
||||
payload.kind = "vin";
|
||||
payload.vin = String(q.vin ?? "").trim();
|
||||
break;
|
||||
|
||||
case "namerecid":
|
||||
payload.kind = "nameRecId";
|
||||
payload.nameRecId = String(q.nameRecId ?? q.custId ?? "").trim();
|
||||
@@ -84,16 +84,15 @@ function toCombinedSearchPayload(args = {}) {
|
||||
payload.kind = "stkNo";
|
||||
payload.stkNo = String(q.stkNo ?? q.stock ?? "").trim();
|
||||
break;
|
||||
|
||||
case "name": {
|
||||
payload.kind = "name";
|
||||
const n = q.name;
|
||||
// STRING => last-name-only intent
|
||||
if (typeof n === "string") {
|
||||
const last = n.trim();
|
||||
if (last) payload.name = { name: last }; // <LName Name="..."/>
|
||||
break;
|
||||
}
|
||||
// OBJECT => always treat as FullName (even if only one of the parts is present)
|
||||
const fname = n?.fname && String(n.fname).trim();
|
||||
const lname = n?.lname && String(n.lname).trim();
|
||||
const mname = n?.mname && String(n.mname).trim();
|
||||
@@ -127,6 +126,7 @@ function toCombinedSearchPayload(args = {}) {
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combined customer/service/vehicle search
|
||||
* @param bodyshop - bodyshop row (must include rr_dealerid & rr_configuration with store/branch)
|
||||
@@ -146,8 +146,8 @@ async function rrCombinedSearch(bodyshop, args = {}) {
|
||||
*/
|
||||
async function rrGetAdvisors(bodyshop, args = {}) {
|
||||
const { client, opts } = buildClientAndOpts(bodyshop);
|
||||
// Allow friendly department values
|
||||
const dep = (args.department || "").toString().toUpperCase();
|
||||
// Accept either department or departmentType from FE
|
||||
const dep = String(args.department ?? args.departmentType ?? "").toUpperCase();
|
||||
const department =
|
||||
dep === "BODY" || dep === "BODYSHOP" ? "B" : dep === "SERVICE" ? "S" : dep === "PARTS" ? "P" : dep || "B";
|
||||
|
||||
@@ -160,8 +160,36 @@ 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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user