feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Checkpoint
This commit is contained in:
79
server/rr/rr-constants.js
Normal file
79
server/rr/rr-constants.js
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
RR_TIMEOUT_MS,
|
||||
RR_NAMESPACE_URI,
|
||||
RR_DEFAULT_MAX_RESULTS,
|
||||
RR_ACTIONS,
|
||||
RR_SOAP_HEADERS,
|
||||
buildSoapEnvelope,
|
||||
getBaseRRConfig
|
||||
};
|
||||
Reference in New Issue
Block a user