feature/Reynolds-and-Reynolds-DMS-API-Integration -Expand
This commit is contained in:
@@ -1,21 +1,58 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// Reynolds & Reynolds (RR) lookup helpers.
|
||||
// Uses MakeRRCall + RRActions from rr-helpers, and shared response validation
|
||||
// from rr-error.
|
||||
//
|
||||
// What’s 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,
|
||||
|
||||
Reference in New Issue
Block a user