IO-233 WIP CDK
This commit is contained in:
@@ -181,6 +181,8 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) {
|
||||
"DEBUG",
|
||||
`{8} Successfully posted sransaction to DMS.`
|
||||
);
|
||||
|
||||
await MarkJobExported(socket, socket.JobData.id);
|
||||
} else {
|
||||
//Get the error code
|
||||
CdkBase.createLogEvent(
|
||||
@@ -217,6 +219,7 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) {
|
||||
"ERROR",
|
||||
`Error encountered in CdkSelectedCustomer. ${error}`
|
||||
);
|
||||
await InsertFailedExportLog(socket, error);
|
||||
} finally {
|
||||
//Ensure we always insert logEvents
|
||||
//GQL to insert logevents.
|
||||
@@ -568,7 +571,7 @@ async function InsertDmsCustomer(socket, newCustomerNumber) {
|
||||
await soapClientCustomerInsertUpdate.insertAsync(
|
||||
{
|
||||
arg0: CDK_CREDENTIALS,
|
||||
arg1: { dealerId: socket.JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
||||
arg1: { dealerId: socket.JobData.bodyshop.cdk_dealerid },
|
||||
arg2: { userId: null },
|
||||
arg3: {
|
||||
//Copied the required fields from the other integration.
|
||||
@@ -1219,3 +1222,44 @@ async function DeleteDmsWip(socket) {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function MarkJobExported(socket, jobid) {
|
||||
CdkBase.createLogEvent(socket, "DEBUG", `Querying job data for id ${jobid}`);
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` })
|
||||
.request(queries.MARK_JOB_EXPORTED, {
|
||||
jobId: jobid,
|
||||
job: {
|
||||
status:
|
||||
socket.JobData.bodyshop.md_ro_statuses.default_exported ||
|
||||
"Exported*",
|
||||
date_exported: new Date(),
|
||||
},
|
||||
log: {
|
||||
bodyshopid: socket.JobData.bodyshop.id,
|
||||
jobid: jobid,
|
||||
successful: true,
|
||||
useremail: socket.user.email,
|
||||
},
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function InsertFailedExportLog(socket, error) {
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {});
|
||||
const result = await client
|
||||
.setHeaders({ Authorization: `Bearer ${socket.handshake.auth.token}` })
|
||||
.request(queries.INSERT_EXPORT_LOG, {
|
||||
log: {
|
||||
bodyshopid: socket.JobData.bodyshop.id,
|
||||
jobid: socket.JobData.id,
|
||||
successful: false,
|
||||
message: [error],
|
||||
useremail: socket.user.email,
|
||||
},
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user