feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Expanded Logs / Formatting change

This commit is contained in:
Dave
2025-11-12 17:01:54 -05:00
parent 556cd993b9
commit 90f653c0b7
13 changed files with 444 additions and 254 deletions

View File

@@ -4,7 +4,7 @@ const { getRRConfigFromBodyshop } = require("./rr-config");
/**
* Build an RR client + common opts from a bodyshop row
*/
function buildClientAndOpts(bodyshop) {
const buildClientAndOpts = (bodyshop) => {
const cfg = getRRConfigFromBodyshop(bodyshop);
const client = new RRClient({
@@ -30,13 +30,13 @@ function buildClientAndOpts(bodyshop) {
};
return { client, opts };
}
};
/**
* Normalize the combined-search arguments into the RR shape.
* We infer `kind` if not provided, based on the first detectable field.
*/
function toCombinedSearchPayload(args = {}) {
const toCombinedSearchPayload = (args = {}) => {
const q = { ...args };
// Decide kind if not provided
@@ -125,26 +125,26 @@ function toCombinedSearchPayload(args = {}) {
if (q.license && payload.kind !== "license") payload.license = String(q.license).trim();
return payload;
}
};
/**
* Combined customer/service/vehicle search
* @param bodyshop - bodyshop row (must include rr_dealerid & rr_configuration with store/branch)
* @param args - search inputs (phone | license | vin | nameRecId | name | stkNo)
*/
async function rrCombinedSearch(bodyshop, args = {}) {
const rrCombinedSearch = async (bodyshop, args = {}) => {
const { client, opts } = buildClientAndOpts(bodyshop);
const payload = toCombinedSearchPayload(args);
const res = await client.combinedSearch(payload, opts);
return res?.data ?? res; // lib returns { success, data, ... }
}
};
/**
* Advisors lookup
* @param bodyshop
* @param args - { department: 'B'|'S'|'P'|string, advisorNumber?: string }
*/
async function rrGetAdvisors(bodyshop, args = {}) {
const rrGetAdvisors = async (bodyshop, args = {}) => {
const { client, opts } = buildClientAndOpts(bodyshop);
// Accept either department or departmentType from FE
const dep = String(args.department ?? args.departmentType ?? "").toUpperCase();
@@ -158,7 +158,7 @@ async function rrGetAdvisors(bodyshop, args = {}) {
const res = await client.getAdvisors(payload, opts);
return res?.data ?? res;
}
};
module.exports = {
rrCombinedSearch,