+ {Fortellis.treatment === "on" && (
+
+ )}
{
+ const { command } = result;
+ console.log("*** ~ axiosCurlirize ~ command:", command);
+
+ // if (err) {
+ // use your logger here
+ // } else {
+ // }
+});
const getTransactionType = (jobid) => `fortellis:${jobid}`;
const defaultFortellisTTL = 60 * 60;
@@ -100,10 +111,11 @@ async function GetDepartmentId({ apiName, debug = false, SubscriptionMeta }) {
);
console.log("===========");
}
+ //TODO: Verify how to select the correct department.
const departmentIds2 = SubscriptionMeta.apiDmsInfo //Get the subscription object.
.find((info) => info.name === apiName)?.departments; //Departments are categorized by API name and have an array of departments.
- return departmentIds2[0].id; //TODO: This makes the assumption that there is only 1 department.
+ return departmentIds2 && departmentIds2[0] && departmentIds2[0].id; //TODO: This makes the assumption that there is only 1 department.
}
//Highest level function call to make a call to fortellis. This should be the only call required, and it will handle all the logic for making the call.
@@ -114,13 +126,17 @@ async function MakeFortellisCall({
body = {},
type = "post",
debug = true,
+ requestPathParams,
+ requestSearchParams = [], //Array of key/value strings like [["key", "value"]]
jobid,
redisHelpers,
- socket
+ socket,
}) {
const { setSessionTransactionData, getSessionTransactionData } = redisHelpers;
- if (debug) logger.log(`Executing ${type} to ${url}`);
+ const fullUrl = constructFullUrl({ url, pathParams: requestPathParams, requestSearchParams });
+
+ if (debug) logger.log(`Executing ${type} to ${fullUrl}`);
const ReqId = uuid();
const access_token = await GetAuthToken();
const SubscriptionMeta = await FetchSubscriptions({ redisHelpers, socket, jobid });
@@ -138,18 +154,18 @@ async function MakeFortellisCall({
switch (type) {
case "post":
default:
- result = await axios.post(url, body, {
+ result = await axios.post(fullUrl, body, {
headers: {
Authorization: `Bearer ${access_token}`,
"Subscription-Id": SubscriptionMeta.subscriptionId,
"Request-Id": ReqId,
- "Department-Id": DepartmentId,
+ ...DepartmentId && { "Department-Id": DepartmentId },
...headers
}
});
break;
case "get":
- result = await axios.get(url, {
+ result = await axios.get(fullUrl, {
headers: {
Authorization: `Bearer ${access_token}`,
"Subscription-Id": SubscriptionMeta.subscriptionId,
@@ -229,10 +245,31 @@ const FortellisActions = {
type: "get",
apiName: "Service Vehicle - Query Vehicles"
},
+ GetVehicleId: {
+ url: isProduction
+ ? "https://api.fortellis.io/cdk/drive/service-vehicle-mgmt/v2/vehicle-ids/" //Request path params of vins
+ : "https://api.fortellis.io/cdk-test/drive/service-vehicle-mgmt/v2/vehicle-ids/",
+ type: "get",
+ apiName: "CDK Drive Post Service Vehicle",
+ },
+ GetVehicleById: {
+ url: isProduction
+ ? "https://api.fortellis.io/cdk/drive/service-vehicle-mgmt/v2/" //Request path params of vehicleId
+ : "https://api.fortellis.io/cdk-test/drive/service-vehicle-mgmt/v2/",
+ type: "get",
+ apiName: "CDK Drive Post Service Vehicle",
+ },
+ QueryCustomerByName: {
+ url: isProduction
+ ? "https://api.fortellis.io/cdk/drive/customerpost/v1/search"
+ : "https://api.fortellis.io/cdk-test/drive/customerpost/v1/search",
+ type: "get",
+ apiName: "CDK Drive Post Customer",
+ },
GetCOA: {
type: "get",
apiName: "CDK Drive Post Accounts GL WIP",
- url: `https://api.fortellis.io/cdk-test/drive/chartofaccounts/v2/bulk`,
+ url: `https://api.fortellis.io/cdk-test/drive/chartofaccounts/v2/bulk/`,
waitForResult: true
}
};
@@ -243,6 +280,17 @@ const FortellisCacheEnums = {
DepartmentId: "DepartmentId"
};
+function constructFullUrl({ url, pathParams = "", requestSearchParams = [] }) {
+ // Ensure the base URL ends with a single "/"
+ url = url.replace(/\/+$/, "/");
+ const fullPath = pathParams ? `${url}${pathParams}` : url;
+ const searchParams = new URLSearchParams(requestSearchParams).toString();
+ const fullUrl = searchParams ? `${fullPath}?${searchParams}` : fullPath;
+ return fullUrl;
+}
+
+
+
module.exports = {
GetAuthToken,
FortellisCacheEnums,
diff --git a/server/fortellis/fortellis-logger.js b/server/fortellis/fortellis-logger.js
index 16af8b60c..9cf296634 100644
--- a/server/fortellis/fortellis-logger.js
+++ b/server/fortellis/fortellis-logger.js
@@ -1,7 +1,7 @@
const logger = require("../utils/logger");
const CreateFortellisLogEvent = (socket, level, message, txnDetails) => {
- //TODO: Add detaisl to track the whole transaction between Fortellis and the server.
+ //TODO: Add detaisl to track the whole transaction between Fortellis and the server.
logger.log("fortellis-log-event", level, socket?.user?.email, null, { wsmessage: message, txnDetails });
socket.emit("fortellis-log-event", { level, message, txnDetails });
};
diff --git a/server/fortellis/fortellis.js b/server/fortellis/fortellis.js
index 156a3fc14..b36310fa0 100644
--- a/server/fortellis/fortellis.js
+++ b/server/fortellis/fortellis.js
@@ -14,10 +14,11 @@ const {
defaultFortellisTTL,
FortellisCacheEnums
} = require("./fortellis-helpers");
+const { last } = require("lodash");
// const moment = require("moment-timezone");
-// const replaceSpecialRegex = /[^a-zA-Z0-9 .,\n #]+/g;
+const replaceSpecialRegex = /[^a-zA-Z0-9 .,\n #]+/g;
async function FortellisJobExport({
socket,
@@ -37,10 +38,6 @@ async function FortellisJobExport({
getSessionTransactionData,
clearSessionTransactionData
} = redisHelpers;
- // ////Store the following information into the redis store for this transaction.
- // socket.logEvents = [];
- // socket.recordid = jobid;
- // socket.txEnvelope = txEnvelope;
try {
CreateFortellisLogEvent(socket, "debug", `Received Job export request for id ${jobid}`);
await setSessionTransactionData(
@@ -54,127 +51,133 @@ async function FortellisJobExport({
const JobData = await QueryJobData({ socket, jobid }); //TODO: Need to remove unnecessary stuff here to reduce the payload.
await setSessionTransactionData(socket.id, getTransactionType(jobid), `JobData`, JobData, defaultFortellisTTL);
- // const DealerId = JobData.bodyshop.cdk_dealerid;
-
CreateFortellisLogEvent(socket, "DEBUG", `{1} Begin Calculate DMS Vehicle ID using VIN: ${JobData.v_vin}`);
const DMSVid = await CalculateDmsVid({ socket, JobData, redisHelpers });
await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSVid`, DMSVid, defaultFortellisTTL);
- if (socket.DMSVid.newId === "N") {
+ let DMSVehCustomer;
+ if (DMSVid.newId === "N") {
CreateFortellisLogEvent(
socket,
"DEBUG",
`{2.1} Querying the Vehicle using the DMSVid: ${socket.DMSVid.vehiclesVehId}`
);
- // socket.DMSVeh = await QueryDmsVehicleById(socket, JobData, socket.DMSVid);
+ const DMSVeh = await QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid });
+ await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSVeh`, DMSVeh, defaultFortellisTTL);
- // const DMSVehCustomer =
- // socket.DMSVeh && socket.DMSVeh.owners && socket.DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
+ const DMSVehCustomerFromVehicle =
+ DMSVeh && DMSVeh.owners && DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
- // if (DMSVehCustomer && DMSVehCustomer.id && DMSVehCustomer.id.value) {
- // CdkBase.createLogEvent(
- // socket,
- // "DEBUG",
- // `{2.2} Querying the Customer using the ID from DMSVeh: ${DMSVehCustomer.id.value}`
- // );
- // socket.DMSVehCustomer = await QueryDmsCustomerById(socket, JobData, DMSVehCustomer.id.value);
+ if (DMSVehCustomerFromVehicle && DMSVehCustomerFromVehicle.id && DMSVehCustomerFromVehicle.id.value) {
+ CreateFortellisLogEvent(
+ socket,
+ "DEBUG",
+ `{2.2} Querying the Customer using the ID from DMSVeh: ${DMSVehCustomerFromVehicle.id.value}`
+ );
+ DMSVehCustomer = await QueryDmsCustomerById({ socket, redisHelpers, JobData, CustomerId: DMSVehCustomerFromVehicle.id.value });
+ await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSVehCustomer`, DMSVehCustomer, defaultFortellisTTL);
+ }
}
+ CreateFortellisLogEvent(socket, "DEBUG", `{2.3} Querying the Customer using the name.`);
- // CdkBase.createLogEvent(socket, "DEBUG", `{2.3} Querying the Customer using the name.`);
+ const DMSCustList = await QueryDmsCustomerByName({ socket, redisHelpers, JobData });
+ await setSessionTransactionData(socket.id, getTransactionType(jobid), `DMSCustList`, DMSCustList, defaultFortellisTTL);
- // socket.DMSCustList = await QueryDmsCustomerByName(socket, JobData);
- // socket.emit("cdk-select-customer", [
- // ...(socket.DMSVehCustomer ? [{ ...socket.DMSVehCustomer, vinOwner: true }] : []),
- // ...socket.DMSCustList
- // ]);
+ socket.emit("fortellis-select-customer", [
+ ...(DMSVehCustomer ? [{ ...DMSVehCustomer, vinOwner: true }] : []),
+ ...DMSCustList
+ ]);
+
} catch (error) {
CreateFortellisLogEvent(socket, "ERROR", `Error in FortellisJobExport - ${error}`, {
error: error.message,
stack: error.stack
});
- //CdkBase.createLogEvent(socket, "ERROR", `Error encountered in CdkJobExport. ${error}`);
}
-
- // async function CdkSelectedCustomer(socket, selectedCustomerId) {
- // try {
- // socket.selectedCustomerId = selectedCustomerId;
- // if (selectedCustomerId) {
- // CdkBase.createLogEvent(socket, "DEBUG", `{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`);
- // socket.DMSCust = await QueryDmsCustomerById(socket, socket.JobData, selectedCustomerId);
- // } else {
- // CdkBase.createLogEvent(socket, "DEBUG", `{3.2} Generating a new customer ID.`);
- // const newCustomerId = await GenerateDmsCustomerNumber(socket);
- // CdkBase.createLogEvent(socket, "DEBUG", `{3.3} Inserting new customer with ID: ${newCustomerId}`);
- // socket.DMSCust = await InsertDmsCustomer(socket, newCustomerId);
- // }
-
- // if (socket.DMSVid.newId === "Y") {
- // CdkBase.createLogEvent(socket, "DEBUG", `{4.1} Inserting new vehicle with ID: ID ${socket.DMSVid.vehiclesVehId}`);
- // socket.DMSVeh = await InsertDmsVehicle(socket);
- // } else {
- // CdkBase.createLogEvent(
- // socket,
- // "DEBUG",
- // `{4.2} Querying Existing Vehicle using ID ${socket.DMSVid.vehiclesVehId}`
- // );
- // socket.DMSVeh = await QueryDmsVehicleById(socket, socket.JobData, socket.DMSVid);
- // CdkBase.createLogEvent(socket, "DEBUG", `{4.3} Updating Existing Vehicle to associate to owner.`);
- // socket.DMSVeh = await UpdateDmsVehicle(socket);
- // }
-
- // CdkBase.createLogEvent(socket, "DEBUG", `{5} Creating Transaction header with Dms Start WIP`);
- // socket.DMSTransHeader = await InsertDmsStartWip(socket);
- // CdkBase.createLogEvent(socket, "DEBUG", `{5.1} Creating Transaction with ID ${socket.DMSTransHeader.transID}`);
-
- // socket.DMSBatchTxn = await InsertDmsBatchWip(socket);
- // CdkBase.createLogEvent(
- // socket,
- // "DEBUG",
- // `{6} Attempting to post Transaction with ID ${socket.DMSTransHeader.transID}`
- // );
- // socket.DmsBatchTxnPost = await PostDmsBatchWip(socket);
- // if (socket.DmsBatchTxnPost.code === "success") {
- // //something
- // CdkBase.createLogEvent(socket, "DEBUG", `{6} Successfully posted sransaction to DMS.`);
-
- // await MarkJobExported(socket, socket.JobData.id);
-
- // CdkBase.createLogEvent(socket, "DEBUG", `{5} Updating Service Vehicle History.`);
- // socket.DMSVehHistory = await InsertServiceVehicleHistory(socket);
- // socket.emit("export-success", socket.JobData.id);
- // } else {
- // //Get the error code
- // CdkBase.createLogEvent(
- // socket,
- // "DEBUG",
- // `{6.1} Getting errors for Transaction ID ${socket.DMSTransHeader.transID}`
- // );
- // socket.DmsError = await QueryDmsErrWip(socket);
- // //Delete the transaction
- // CdkBase.createLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${socket.DMSTransHeader.transID}`);
- // socket.DmsBatchTxnPost = await DeleteDmsWip(socket);
-
- // socket.DmsError.errMsg
- // .split("|")
- // .map(
- // (e) =>
- // e !== null &&
- // e !== "" &&
- // CdkBase.createLogEvent(socket, "ERROR", `Error(s) encountered in posting transaction. ${e}`)
- // );
- // }
- // } catch (error) {
- // CdkBase.createLogEvent(socket, "ERROR", `Error encountered in CdkSelectedCustomer. ${error}`);
- // await InsertFailedExportLog(socket, error);
- // } finally {
- // //Ensure we always insert logEvents
- // //GQL to insert logevents.
-
- // CdkBase.createLogEvent(socket, "DEBUG", `Capturing log events to database.`);
- // }
}
+
+
+// async function CdkSelectedCustomer(socket, selectedCustomerId) {
+// try {
+// socket.selectedCustomerId = selectedCustomerId;
+// if (selectedCustomerId) {
+// CdkBase.createLogEvent(socket, "DEBUG", `{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`);
+// socket.DMSCust = await QueryDmsCustomerById(socket, socket.JobData, selectedCustomerId);
+// } else {
+// CdkBase.createLogEvent(socket, "DEBUG", `{3.2} Generating a new customer ID.`);
+// const newCustomerId = await GenerateDmsCustomerNumber(socket);
+// CdkBase.createLogEvent(socket, "DEBUG", `{3.3} Inserting new customer with ID: ${newCustomerId}`);
+// socket.DMSCust = await InsertDmsCustomer(socket, newCustomerId);
+// }
+
+// if (socket.DMSVid.newId === "Y") {
+// CdkBase.createLogEvent(socket, "DEBUG", `{4.1} Inserting new vehicle with ID: ID ${socket.DMSVid.vehiclesVehId}`);
+// socket.DMSVeh = await InsertDmsVehicle(socket);
+// } else {
+// CdkBase.createLogEvent(
+// socket,
+// "DEBUG",
+// `{4.2} Querying Existing Vehicle using ID ${socket.DMSVid.vehiclesVehId}`
+// );
+// socket.DMSVeh = await QueryDmsVehicleById(socket, socket.JobData, socket.DMSVid);
+// CdkBase.createLogEvent(socket, "DEBUG", `{4.3} Updating Existing Vehicle to associate to owner.`);
+// socket.DMSVeh = await UpdateDmsVehicle(socket);
+// }
+
+// CdkBase.createLogEvent(socket, "DEBUG", `{5} Creating Transaction header with Dms Start WIP`);
+// socket.DMSTransHeader = await InsertDmsStartWip(socket);
+// CdkBase.createLogEvent(socket, "DEBUG", `{5.1} Creating Transaction with ID ${socket.DMSTransHeader.transID}`);
+
+// socket.DMSBatchTxn = await InsertDmsBatchWip(socket);
+// CdkBase.createLogEvent(
+// socket,
+// "DEBUG",
+// `{6} Attempting to post Transaction with ID ${socket.DMSTransHeader.transID}`
+// );
+// socket.DmsBatchTxnPost = await PostDmsBatchWip(socket);
+// if (socket.DmsBatchTxnPost.code === "success") {
+// //something
+// CdkBase.createLogEvent(socket, "DEBUG", `{6} Successfully posted sransaction to DMS.`);
+
+// await MarkJobExported(socket, socket.JobData.id);
+
+// CdkBase.createLogEvent(socket, "DEBUG", `{5} Updating Service Vehicle History.`);
+// socket.DMSVehHistory = await InsertServiceVehicleHistory(socket);
+// socket.emit("export-success", socket.JobData.id);
+// } else {
+// //Get the error code
+// CdkBase.createLogEvent(
+// socket,
+// "DEBUG",
+// `{6.1} Getting errors for Transaction ID ${socket.DMSTransHeader.transID}`
+// );
+// socket.DmsError = await QueryDmsErrWip(socket);
+// //Delete the transaction
+// CdkBase.createLogEvent(socket, "DEBUG", `{6.2} Deleting Transaction ID ${socket.DMSTransHeader.transID}`);
+// socket.DmsBatchTxnPost = await DeleteDmsWip(socket);
+
+// socket.DmsError.errMsg
+// .split("|")
+// .map(
+// (e) =>
+// e !== null &&
+// e !== "" &&
+// CdkBase.createLogEvent(socket, "ERROR", `Error(s) encountered in posting transaction. ${e}`)
+// );
+// }
+// } catch (error) {
+// CdkBase.createLogEvent(socket, "ERROR", `Error encountered in CdkSelectedCustomer. ${error}`);
+// await InsertFailedExportLog(socket, error);
+// } finally {
+// //Ensure we always insert logEvents
+// //GQL to insert logevents.
+
+// CdkBase.createLogEvent(socket, "DEBUG", `Capturing log events to database.`);
+// }
+//}
+
// exports.CdkSelectedCustomer = CdkSelectedCustomer;
async function QueryJobData({ socket, jobid }) {
@@ -188,170 +191,107 @@ async function QueryJobData({ socket, jobid }) {
async function CalculateDmsVid({ socket, JobData, redisHelpers }) {
try {
const result = await MakeFortellisCall({
- ...FortellisActions.QueryVehicles,
+ ...FortellisActions.GetVehicleId,
+ requestPathParams: JobData.v_vin,
headers: {},
redisHelpers,
socket,
jobid: JobData.id,
- body: {
- vin: JobData.v_vin
- //Include the contents of the call here.
- }
+ body: {},
+
});
- // const soapClientVehicleInsertUpdate = await soap.createClientAsync(CdkWsdl.VehicleInsertUpdate);
- // const soapResponseVehicleInsertUpdate = await soapClientVehicleInsertUpdate.getVehIdsAsync({
- // arg0: CDK_CREDENTIALS,
- // arg1: { id: JobData.bodyshop.cdk_dealerid },
- // arg2: { VIN: JobData.v_vin }
- // });
- // const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
- // CdkBase.createXmlEvent(socket, rawRequest, `soapClientVehicleInsertUpdate.getVehIdsAsync request.`);
- // CdkBase.createXmlEvent(socket, rawResponse, `soapClientVehicleInsertUpdate.getVehIdsAsync response.`);
- // CdkBase.createLogEvent(
- // socket,
- // "SILLY",
- // `soapClientVehicleInsertUpdate.getVehIdsAsync Result ${JSON.stringify(result, null, 2)}`
- // );
- // CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
- // //if (result && result.return && result.return.length > 1) {
- // return result.return.find((r) => r.vehiclesVehId);
- // //}
- //return result && result.return && result.return[0];
+ return result;
} catch (error) {
CreateFortellisLogEvent(socket, "ERROR", `Error in CalculateDmsVid - ${error}`, { request: error.request });
- // CdkBase.createXmlEvent(socket, error.request, `soapClientVehicleInsertUpdate.getVehIdsAsync request.`, true);
-
- // CdkBase.createXmlEvent(
- // socket,
- // error.response && error.response.data,
- // `soapClientVehicleInsertUpdate.getVehIdsAsync response.`,
- // true
- // );
- // CdkBase.createLogEvent(socket, "ERROR", `{1} Error in CalculateDmsVid - ${error}`);
- // throw new Error(error);
}
}
-// async function QueryDmsVehicleById(socket, JobData, DMSVid) {
-// try {
-// const soapClientVehicleInsertUpdate = await soap.createClientAsync(CdkWsdl.VehicleInsertUpdate);
+async function QueryDmsVehicleById({ socket, redisHelpers, JobData, DMSVid }) {
+ try {
+ const result = await MakeFortellisCall({
+ ...FortellisActions.GetVehicleById,
+ requestPathParams: DMSVid.vehiclesVehId,
+ headers: {},
+ redisHelpers,
+ socket,
+ jobid: JobData.id,
+ body: {},
+ });
+ const VehicleFromDMS = result && result.return && result.return.vehicle;
+ return VehicleFromDMS;
+ } catch (error) {
+ CreateFortellisLogEvent(socket, "ERROR", `Error in QueryDmsVehicleById - ${error}`, { request: error.request });
+ }
+}
-// const soapResponseVehicleInsertUpdate = await soapClientVehicleInsertUpdate.readAsync({
-// arg0: CDK_CREDENTIALS,
-// arg1: { id: JobData.bodyshop.cdk_dealerid },
-// arg2: {
-// fileType: "VEHICLES",
-// vehiclesVehicleId: DMSVid.vehiclesVehId
-// }
-// });
+async function QueryDmsCustomerById({ socket, redisHelpers, JobData, CustomerId }) {
+ try {
+ const soapClientCustomerInsertUpdate = await soap.createClientAsync(CdkWsdl.CustomerInsertUpdate);
+ const soapResponseCustomerInsertUpdate = await soapClientCustomerInsertUpdate.readAsync({
+ arg0: CDK_CREDENTIALS,
+ arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
+ arg2: {
+ // userId: CustomerId,
+ },
+ arg3: CustomerId
+ });
-// const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
+ const [result, rawResponse, , rawRequest] = soapResponseCustomerInsertUpdate;
-// CdkBase.createXmlEvent(socket, rawRequest, `soapClientVehicleInsertUpdate.readAsync request.`);
+ CdkBase.createXmlEvent(socket, rawRequest, `soapClientCustomerInsertUpdate.readAsync request.`);
-// CdkBase.createLogEvent(
-// socket,
-// "SILLY",
-// `soapClientVehicleInsertUpdate.readAsync Result ${JSON.stringify(result, null, 2)}`
-// );
-// CdkBase.createXmlEvent(socket, rawResponse, `soapClientVehicleInsertUpdate.readAsync response.`);
-// CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
-// const VehicleFromDMS = result && result.return && result.return.vehicle;
-// return VehicleFromDMS;
-// } catch (error) {
-// CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsVehicleById - ${error}`);
-// throw new Error(error);
-// }
-// }
+ CdkBase.createXmlEvent(socket, rawResponse, `soapClientCustomerInsertUpdate.readAsync response.`);
+ CdkBase.createLogEvent(
+ socket,
+ "SILLY",
+ `soapClientCustomerInsertUpdate.readAsync Result ${JSON.stringify(result, null, 2)}`
+ );
+ CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
+ const CustomersFromDms = result && result.return && result.return.customerParty;
+ return CustomersFromDms;
+ } catch (error) {
+ CdkBase.createXmlEvent(socket, error.request, `soapClientCustomerInsertUpdate.readAsync request.`, true);
-// async function QueryDmsCustomerById(socket, JobData, CustomerId) {
-// try {
-// const soapClientCustomerInsertUpdate = await soap.createClientAsync(CdkWsdl.CustomerInsertUpdate);
-// const soapResponseCustomerInsertUpdate = await soapClientCustomerInsertUpdate.readAsync({
-// arg0: CDK_CREDENTIALS,
-// arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
-// arg2: {
-// // userId: CustomerId,
-// },
-// arg3: CustomerId
-// });
+ CdkBase.createXmlEvent(
+ socket,
+ error.response && error.response.data,
+ `soapClientCustomerInsertUpdate.readAsync response.`,
+ true
+ );
-// const [result, rawResponse, , rawRequest] = soapResponseCustomerInsertUpdate;
+ CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsCustomerById - ${error}`);
+ throw new Error(error);
+ }
+}
-// CdkBase.createXmlEvent(socket, rawRequest, `soapClientCustomerInsertUpdate.readAsync request.`);
+async function QueryDmsCustomerByName({ socket, redisHelpers, JobData }) {
+ const ownerName =
+ JobData.ownr_co_nm && JobData.ownr_co_nm.trim() !== ""
+ ? [["lastName", JobData.ownr_co_nm.replace(replaceSpecialRegex, "")]]
+ : [["firstName", JobData.ownr_fn.replace(replaceSpecialRegex, "")], ["lastName", JobData.ownr_ln.replace(replaceSpecialRegex, "")]];
-// CdkBase.createXmlEvent(socket, rawResponse, `soapClientCustomerInsertUpdate.readAsync response.`);
-// CdkBase.createLogEvent(
-// socket,
-// "SILLY",
-// `soapClientCustomerInsertUpdate.readAsync Result ${JSON.stringify(result, null, 2)}`
-// );
-// CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
-// const CustomersFromDms = result && result.return && result.return.customerParty;
-// return CustomersFromDms;
-// } catch (error) {
-// CdkBase.createXmlEvent(socket, error.request, `soapClientCustomerInsertUpdate.readAsync request.`, true);
+ CreateFortellisLogEvent(
+ socket,
+ "DEBUG",
+ `Begin query DMS Customer by Name using ${JSON.stringify(ownerName)}`
+ );
-// CdkBase.createXmlEvent(
-// socket,
-// error.response && error.response.data,
-// `soapClientCustomerInsertUpdate.readAsync response.`,
-// true
-// );
+ try {
+ const result = await MakeFortellisCall({
+ ...FortellisActions.QueryCustomerByName,
+ requestSearchParams: ownerName,
+ headers: {},
+ redisHelpers,
+ socket,
+ jobid: JobData.id,
+ body: {},
-// CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsCustomerById - ${error}`);
-// throw new Error(error);
-// }
-// }
-
-// async function QueryDmsCustomerByName(socket, JobData) {
-// const ownerName = (
-// JobData.ownr_co_nm && JobData.ownr_co_nm.trim() !== ""
-// ? JobData.ownr_co_nm
-// : `${JobData.ownr_ln},${JobData.ownr_fn}`
-// ).replace(replaceSpecialRegex, "");
-
-// CdkBase.createLogEvent(socket, "DEBUG", `Begin Query DMS Customer by Name using: ${ownerName}`);
-
-// try {
-// const soapClientCustomerSearch = await soap.createClientAsync(CdkWsdl.CustomerSearch);
-// const soapResponseCustomerSearch = await soapClientCustomerSearch.executeSearchAsync({
-// arg0: CDK_CREDENTIALS,
-// arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
-// arg2: {
-// verb: "EXACT",
-// key: ownerName
-// }
-// });
-
-// const [result, rawResponse, , rawRequest] = soapResponseCustomerSearch;
-
-// CdkBase.createXmlEvent(socket, rawRequest, `soapClientCustomerSearch.executeSearchBulkAsync request.`);
-
-// CdkBase.createXmlEvent(socket, rawResponse, `soapClientCustomerSearch.executeSearchBulkAsync response.`);
-
-// CdkBase.createLogEvent(
-// socket,
-// "SILLY",
-// `soapClientCustomerSearch.executeSearchBulkAsync Result ${JSON.stringify(result, null, 2)}`
-// );
-// CheckCdkResponseForError(socket, soapResponseCustomerSearch);
-// const CustomersFromDms = (result && result.return) || [];
-// return CustomersFromDms;
-// } catch (error) {
-// CdkBase.createXmlEvent(socket, error.request, `soapClientCustomerSearch.executeSearchBulkAsync request.`, true);
-
-// CdkBase.createXmlEvent(
-// socket,
-// error.response && error.response.data,
-// `soapClientCustomerSearch.executeSearchBulkAsync response.`,
-// true
-// );
-
-// CdkBase.createLogEvent(socket, "ERROR", `Error in QueryDmsCustomerByName - ${error}`);
-// throw new Error(error);
-// }
-// }
+ });
+ return result.data;
+ } catch (error) {
+ CreateFortellisLogEvent(socket, "ERROR", `Error in QueryDmsCustomerByName - ${error}`, { request: error.request });
+ }
+}
// async function GenerateDmsCustomerNumber(socket) {
// try {