feature/Reynolds-and-Reynolds-DMS-API-Integration -Expand

This commit is contained in:
Dave
2025-10-01 17:11:34 -04:00
parent 42027f0858
commit 24f017bfd2
11 changed files with 744 additions and 333 deletions

View File

@@ -1,21 +1,58 @@
// -----------------------------------------------------------------------------
// Reynolds & Reynolds (RR) lookup helpers.
// Uses MakeRRCall + RRActions from rr-helpers, and shared response validation
// from rr-error.
//
// Whats still missing / to confirm against the Rome/RR PDFs:
// - Final query param names and value formats for the “combined search”
// (customer + vehicle), advisors directory, and parts lookup.
// - Any RR-required headers (dealer/site/location ids) — add in rr-helpers
// via the MakeRRCall default headers if needed.
// - Final success envelope checks in assertRrOk.
// -----------------------------------------------------------------------------
const { MakeRRCall, RRActions } = require("./rr-helpers");
const { assertRrOk } = require("./rr-error");
/**
* RR Combined Search (Customer + Vehicle).
*
* @param {Object} deps
* @param {Socket|ExpressRequest} deps.socket
* @param {Object} deps.redisHelpers
* @param {string|number} deps.jobid - for correlation/logging only
* @param {Array<[string,string]>} [deps.params=[]]
* Example: [["vin", "1HGBH41JXMN109186"], ["lastName","DOE"]]
* @returns {Promise<any>} RR response (envelope TBD)
*/
async function RrCombinedSearch({ socket, redisHelpers, jobid, params = [] }) {
const data = await MakeRRCall({
...RRActions.CombinedSearch, // add to RRActions
requestSearchParams: params, // e.g., [["vin", "XXXX"], ["lastName","DOE"]]
...RRActions.CombinedSearch, // GET /search/v1/customer-vehicle
requestSearchParams: params,
type: "get",
redisHelpers,
socket,
jobid
});
// allowEmpty=true because searches may legitimately return 0 rows
return assertRrOk(data, { apiName: "RR Combined Search", allowEmpty: true });
}
/**
* RR Get Advisors.
*
* @param {Object} deps
* @param {Socket|ExpressRequest} deps.socket
* @param {Object} deps.redisHelpers
* @param {string|number} deps.jobid
* @param {Array<[string,string]>} [deps.params=[]]
* Example: [["active","true"]]
* @returns {Promise<any>} RR response (envelope TBD)
*/
async function RrGetAdvisors({ socket, redisHelpers, jobid, params = [] }) {
const data = await MakeRRCall({
...RRActions.GetAdvisors, // add
...RRActions.GetAdvisors, // GET /advisors/v1
requestSearchParams: params,
type: "get",
redisHelpers,
@@ -25,9 +62,20 @@ async function RrGetAdvisors({ socket, redisHelpers, jobid, params = [] }) {
return assertRrOk(data, { apiName: "RR Get Advisors", allowEmpty: true });
}
/**
* RR Get Parts.
*
* @param {Object} deps
* @param {Socket|ExpressRequest} deps.socket
* @param {Object} deps.redisHelpers
* @param {string|number} deps.jobid
* @param {Array<[string,string]>} [deps.params=[]]
* Example: [["sku","ABC123"], ["page","1"], ["pageSize","50"]]
* @returns {Promise<any>} RR response (envelope TBD)
*/
async function RrGetParts({ socket, redisHelpers, jobid, params = [] }) {
const data = await MakeRRCall({
...RRActions.GetParts, // add
...RRActions.GetParts, // GET /parts/v1
requestSearchParams: params,
type: "get",
redisHelpers,