WIP Fortellis.

This commit is contained in:
Patrick Fic
2025-04-25 11:58:38 -07:00
parent e2b4b408ed
commit 19ce1c66ad
7 changed files with 895 additions and 414 deletions

View File

@@ -0,0 +1,5 @@
Fortellis Feedback
Create Customer
https://apidocs.fortellis.io/apis/c5cfb5b3-2013-4870-8645-0379c01ae56b
Request Body compoennts do not show on website. Unable to determine which components are required.

View File

@@ -17,7 +17,7 @@ const mapDispatchToProps = (dispatch) => ({
}); });
export default connect(mapStateToProps, mapDispatchToProps)(DmsCustomerSelector); export default connect(mapStateToProps, mapDispatchToProps)(DmsCustomerSelector);
export function DmsCustomerSelector({ bodyshop }) { export function DmsCustomerSelector({ bodyshop, jobid }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [customerList, setcustomerList] = useState([]); const [customerList, setcustomerList] = useState([]);
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -38,7 +38,7 @@ export function DmsCustomerSelector({ bodyshop }) {
if (Fortellis.treatment === "on") { if (Fortellis.treatment === "on") {
const handleFortellisSelectCustomer = (customerList, callback) => { const handleFortellisSelectCustomer = (customerList, callback) => {
setOpen(true); setOpen(true);
setDmsType("fortellis"); setDmsType("cdk");
setcustomerList(customerList); setcustomerList(customerList);
}; };
wsssocket.on("fortellis-select-customer", handleFortellisSelectCustomer); wsssocket.on("fortellis-select-customer", handleFortellisSelectCustomer);
@@ -67,7 +67,11 @@ export function DmsCustomerSelector({ bodyshop }) {
const onUseSelected = () => { const onUseSelected = () => {
setOpen(false); setOpen(false);
socket.emit(`${dmsType}-selected-customer`, selectedCustomer); if (Fortellis.treatment === "on") {
wsssocket.emit(`fortellis-selected-customer`, { selectedCustomerId: selectedCustomer, jobid });
} else {
socket.emit(`${dmsType}-selected-customer`, selectedCustomer);
}
setSelectedCustomer(null); setSelectedCustomer(null);
}; };

View File

@@ -72,7 +72,13 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
const handleFinish = (values) => { const handleFinish = (values) => {
//TODO: Add this as a split instead. //TODO: Add this as a split instead.
if (Fortellis.treatment === "on") { if (Fortellis.treatment === "on") {
wsssocket.emit("fortellis-export-job", { jobid: job.id, txEnvelope: values }); wsssocket.emit("fortellis-export-job", {
jobid: job.id,
txEnvelope: {
...values,
SubscriptionID: "5b527d7d-baf3-40bc-adae-e7a541e37363" //bodyshop.cdk_dealerid
}
});
} else { } else {
socket.emit(`${determineDmsType(bodyshop)}-export-job`, { socket.emit(`${determineDmsType(bodyshop)}-export-job`, {
jobid: job.id, jobid: job.id,

View File

@@ -201,7 +201,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
<DmsPostForm socket={socket} jobId={jobId} job={data && data.jobs_by_pk} logsRef={logsRef} /> <DmsPostForm socket={socket} jobId={jobId} job={data && data.jobs_by_pk} logsRef={logsRef} />
</Col> </Col>
<DmsCustomerSelector /> <DmsCustomerSelector jobid={jobId} />
<Col span={24}> <Col span={24}>
<div ref={logsRef}> <div ref={logsRef}>

View File

@@ -175,6 +175,17 @@ async function MakeFortellisCall({
} }
}); });
break; break;
case "put":
result = await axios.put(fullUrl, body, {
headers: {
Authorization: `Bearer ${access_token}`,
"Subscription-Id": SubscriptionMeta.subscriptionId,
"Request-Id": ReqId,
"Department-Id": DepartmentId,
...headers
}
});
break;
} }
if (debug) { if (debug) {
@@ -266,6 +277,34 @@ const FortellisActions = {
type: "get", type: "get",
apiName: "CDK Drive Post Customer", apiName: "CDK Drive Post Customer",
}, },
ReadCustomer: {
url: isProduction
? "https://api.fortellis.io/cdk/drive/customerpost/v1/" //Customer ID is request param.
: "https://api.fortellis.io/cdk-test/drive/customerpost/v1/",
type: "get",
apiName: "CDK Drive Post Customer",
},
CreateCustomer: {
url: isProduction
? "https://api.fortellis.io/cdk/drive/customerpost/v1/"
: "https://api.fortellis.io/cdk-test/drive/customerpost/v1/",
type: "post",
apiName: "CDK Drive Post Customer",
},
InsertVehicle: {
url: isProduction
? "https://api.fortellis.io/cdk/drive/service-vehicle-mgmt/v2/"
: "https://api.fortellis.io/cdk-test/drive/service-vehicle-mgmt/v2/",
type: "post",
apiName: "CDK Drive Post Service Vehicle",
},
UpdateVehicle: {
url: isProduction
? "https://api.fortellis.io/cdk/drive/service-vehicle-mgmt/v2/"
: "https://api.fortellis.io/cdk-test/drive/service-vehicle-mgmt/v2/",
type: "put",
apiName: "CDK Drive Post Customer",
},
GetCOA: { GetCOA: {
type: "get", type: "get",
apiName: "CDK Drive Post Accounts GL WIP", apiName: "CDK Drive Post Accounts GL WIP",
@@ -277,7 +316,14 @@ const FortellisActions = {
const FortellisCacheEnums = { const FortellisCacheEnums = {
txEnvelope: "txEnvelope", txEnvelope: "txEnvelope",
SubscriptionMeta: "SubscriptionMeta", SubscriptionMeta: "SubscriptionMeta",
DepartmentId: "DepartmentId" DepartmentId: "DepartmentId",
JobData: "JobData",
DMSVid: "DMSVid",
DMSVeh: "DMSVeh",
DMSVehCustomer: "DMSVehCustomer",
DMSCustList: "DMSCustList",
DMSCust: "DMSCust",
selectedCustomerId: "selectedCustomerId",
}; };
function constructFullUrl({ url, pathParams = "", requestSearchParams = [] }) { function constructFullUrl({ url, pathParams = "", requestSearchParams = [] }) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
const { admin } = require("../firebase/firebase-handler"); const { admin } = require("../firebase/firebase-handler");
const FortellisJobExport = require("../fortellis/fortellis").default; const { FortellisJobExport, FortellisSelectedCustomer } = require("../fortellis/fortellis");
const FortellisLogger = require("../fortellis/fortellis-logger"); const FortellisLogger = require("../fortellis/fortellis-logger");
const redisSocketEvents = ({ const redisSocketEvents = ({
@@ -272,6 +272,33 @@ const redisSocketEvents = ({
}); });
} }
}); });
socket.on("fortellis-selected-customer", async ({ jobid, selectedCustomerId }) => {
try {
await FortellisSelectedCustomer({
socket,
redisHelpers: {
setSessionData,
getSessionData,
addUserSocketMapping,
removeUserSocketMapping,
refreshUserSocketTTL,
getUserSocketMappingByBodyshop,
setSessionTransactionData,
getSessionTransactionData,
clearSessionTransactionData
},
ioHelpers: { getBodyshopRoom, getBodyshopConversationRoom },
jobid,
selectedCustomerId
});
} catch (error) {
FortellisLogger(socket, "error", `Error during Fortellis export : ${error.message}`);
logger.log("fortellis-selectd-customer-error", "error", null, null, {
message: error.message,
stack: error.stack
});
}
});
}; };
// Call Handlers // Call Handlers