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

This commit is contained in:
Dave
2025-10-08 13:57:34 -04:00
parent 2ffc4b81f4
commit de02b34a63
28 changed files with 2550 additions and 2443 deletions

View File

@@ -1,79 +1,50 @@
/**
* @file rr-constants.js
* @description Central constants and configuration for Reynolds & Reynolds (R&R) integration.
* Platform-level secrets (API base URL, username, password, ppsysId, dealer/store/branch) are loaded from .env
* Dealer-specific values (overrides) come from bodyshop.rr_configuration.
* STAR-only constants for Reynolds & Reynolds (Rome/RCI)
* Used by rr-helpers.js to build and send SOAP requests.
*/
const RR_TIMEOUT_MS = 30000; // 30-second SOAP call timeout
const RR_NAMESPACE_URI = "http://reynoldsandrey.com/";
const RR_DEFAULT_MAX_RESULTS = 25;
/**
* Maps internal operation names to Reynolds & Reynolds SOAP actions.
* soapAction is sent as the SOAPAction header; URL selection happens in rr-helpers.
*/
const RR_ACTIONS = {
GetAdvisors: { soapAction: "GetAdvisors" },
GetParts: { soapAction: "GetParts" },
CombinedSearch: { soapAction: "CombinedSearch" },
InsertCustomer: { soapAction: "CustomerInsert" },
UpdateCustomer: { soapAction: "CustomerUpdate" },
InsertServiceVehicle: { soapAction: "ServiceVehicleInsert" },
CreateRepairOrder: { soapAction: "RepairOrderInsert" },
UpdateRepairOrder: { soapAction: "RepairOrderUpdate" }
};
/**
* Default SOAP HTTP headers. SOAPAction is dynamically set per request.
*/
const RR_SOAP_HEADERS = {
"Content-Type": "text/xml; charset=utf-8",
SOAPAction: ""
};
/**
* Wraps the rendered XML body inside a SOAP envelope.
* @param {string} xmlBody - Inner request XML
* @param {string} [headerXml] - Optional header XML (already namespaced)
*/
const buildSoapEnvelope = (xmlBody, headerXml = "") => `
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rr="${RR_NAMESPACE_URI}">
<soapenv:Header>
${headerXml}
</soapenv:Header>
<soapenv:Body>
${xmlBody}
</soapenv:Body>
</soapenv:Envelope>
`;
/**
* Loads base configuration for R&R requests from environment variables.
* Dealer-specific overrides come from bodyshop.rr_configuration in the DB.
*/
const getBaseRRConfig = () => ({
// IMPORTANT: RCI Receive endpoint ends with .ashx
baseUrl: process.env.RR_API_BASE_URL || "https://b2b-test.reyrey.com/Sync/RCI/Rome/Receive.ashx",
username: process.env.RR_API_USER || "",
password: process.env.RR_API_PASS || "",
ppsysId: process.env.RR_PPSYS_ID || "",
// Welcome Kit often provides these (used in SOAP header)
dealerNumber: process.env.RR_DEALER_NUMBER || "",
storeNumber: process.env.RR_STORE_NUMBER || "",
branchNumber: process.env.RR_BRANCH_NUMBER || "",
dealerDefault: process.env.RR_DEFAULT_DEALER || "ROME",
timeout: RR_TIMEOUT_MS
exports.RR_NS = Object.freeze({
SOAP_ENV: "http://schemas.xmlsoap.org/soap/envelope/",
SOAP_ENC: "http://schemas.xmlsoap.org/soap/encoding/",
XSD: "http://www.w3.org/2001/XMLSchema",
XSI: "http://www.w3.org/2001/XMLSchema-instance",
WSSE: "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
WSU: "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd",
STAR_TRANSPORT: "http://www.starstandards.org/webservices/2005/10/transport",
STAR_BUSINESS: "http://www.starstandards.org/STAR"
});
module.exports = {
RR_TIMEOUT_MS,
RR_NAMESPACE_URI,
RR_DEFAULT_MAX_RESULTS,
RR_ACTIONS,
RR_SOAP_HEADERS,
buildSoapEnvelope,
getBaseRRConfig
const RR_STAR_SOAP_ACTION = "http://www.starstandards.org/webservices/2005/10/transport/ProcessMessage";
exports.RR_SOAP_ACTION = RR_STAR_SOAP_ACTION;
const RR_SOAP_HEADERS = {
"Content-Type": "text/xml; charset=utf-8",
SOAPAction: RR_STAR_SOAP_ACTION
};
// All STAR-supported actions (mapped to Mustache templates)
exports.RR_ACTIONS = Object.freeze({
CombinedSearch: { template: "CombinedSearch" },
GetAdvisors: { template: "GetAdvisors" },
GetParts: { template: "GetParts" },
InsertCustomer: { template: "InsertCustomer" },
InsertServiceVehicle: { template: "InsertServiceVehicle" },
CreateRepairOrder: { template: "CreateRepairOrder" },
UpdateCustomer: { template: "UpdateCustomer" },
UpdateRepairOrder: { template: "UpdateRepairOrder" }
});
// Base config loader (environment-driven)
exports.getBaseRRConfig = function getBaseRRConfig() {
return {
baseUrl: process.env.RR_BASE_URL,
username: process.env.RR_USERNAME,
password: process.env.RR_PASSWORD,
ppsysId: process.env.RR_PPSYSID, // optional legacy identifier
dealerNumber: process.env.RR_DEALER_NUMBER,
storeNumber: process.env.RR_STORE_NUMBER,
branchNumber: process.env.RR_BRANCH_NUMBER || "01",
wssePasswordType: process.env.RR_WSSE_PASSWORD_TYPE || "Text",
timeout: Number(process.env.RR_TIMEOUT_MS || 30000)
};
};