IO-233 Add soap request structure
This commit is contained in:
@@ -6,31 +6,45 @@ require("dotenv").config({
|
||||
),
|
||||
});
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
const soap = require("soap");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const CdkBase = require("./cdk");
|
||||
const CdkWsdl = require("./cdk-wsdl").default;
|
||||
|
||||
const IMEX_CDK_USER = process.env.IMEX_CDK_USER,
|
||||
IMEX_CDK_PASSWORD = process.env.IMEX_CDK_PASSWORD;
|
||||
|
||||
exports.default = async function (socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`Received Job export request for id ${jobid}`
|
||||
);
|
||||
socket.logEvents = [];
|
||||
try {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`Received Job export request for id ${jobid}`
|
||||
);
|
||||
|
||||
const JobData = await QueryJobData(socket, jobid);
|
||||
const JobData = await QueryJobData(socket, jobid);
|
||||
console.log(JSON.stringify(JobData, null, 2));
|
||||
const DealerId = JobData.bodyshop.cdk_dealerid;
|
||||
|
||||
const DealerId = JobData.bodyshop.dealerid;
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`Dealer ID detected: ${JSON.stringify(DealerId)}`
|
||||
);
|
||||
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`Dealer ID detected: ${JSON.stringify(DealerId)}`
|
||||
);
|
||||
|
||||
await DetermineDMSVid(socket, JobData);
|
||||
// Begin Calculate VID from DMS {1}
|
||||
// Begin Calculate VID from DMS {1}
|
||||
await DetermineDMSVid(socket, JobData);
|
||||
} catch (error) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error encountered in JobExport. ${error}`
|
||||
);
|
||||
} finally {
|
||||
//Ensure we always insert logEvents
|
||||
//GQL to insert logevents.
|
||||
}
|
||||
};
|
||||
|
||||
async function QueryJobData(socket, jobid) {
|
||||
@@ -42,11 +56,32 @@ async function QueryJobData(socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`Job data query result ${JSON.stringify(result)}`
|
||||
`Job data query result ${JSON.stringify(result, null, 2)}`
|
||||
);
|
||||
return result;
|
||||
return result.jobs_by_pk;
|
||||
}
|
||||
|
||||
async function DetermineDMSVid(socket, JobData) {
|
||||
CdkBase.createLogEvent(socket, "TRACE", "{1} Begin Determine DMS VehicleID");
|
||||
|
||||
try {
|
||||
//Create SOAP Request for <getVehIds/>
|
||||
const soapClient = await soap.createClientAsync(CdkWsdl.VehicleSearch);
|
||||
const result = await soapClient.searchIDsByVINAsync(
|
||||
{
|
||||
arg0: { password: IMEX_CDK_PASSWORD, username: IMEX_CDK_USER },
|
||||
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
||||
arg2: { VIN: JobData.v_vin },
|
||||
},
|
||||
|
||||
{}
|
||||
);
|
||||
console.log(result);
|
||||
} catch (error) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error in DetermineDMSVid - ${JSON.stringify(error, null, 2)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
4
server/cdk/cdk-wsdl.js
Normal file
4
server/cdk/cdk-wsdl.js
Normal file
@@ -0,0 +1,4 @@
|
||||
exports.default = {
|
||||
VehicleSearch:
|
||||
"https://uat-3pa.dmotorworks.com/pip-vehicle/services/VehicleSearch?wsdl",
|
||||
};
|
||||
@@ -10,6 +10,7 @@ require("dotenv").config({
|
||||
const { io } = require("../../server");
|
||||
const { admin } = require("../firebase/firebase-handler");
|
||||
const CdkJobExport = require("./cdk-job-export").default;
|
||||
const { isArray } = require("lodash");
|
||||
|
||||
io.use(function (socket, next) {
|
||||
try {
|
||||
@@ -34,7 +35,7 @@ io.use(function (socket, next) {
|
||||
});
|
||||
|
||||
io.on("connection", (socket) => {
|
||||
socket.log_level = "DEBUG";
|
||||
socket.log_level = "TRACE";
|
||||
createLogEvent(socket, "DEBUG", `Connected and Authenticated.`);
|
||||
|
||||
socket.on("set-log-level", (level) => {
|
||||
@@ -63,6 +64,14 @@ function createLogEvent(socket, level, message) {
|
||||
level,
|
||||
message,
|
||||
});
|
||||
|
||||
if (socket.logEvents && isArray(socket.logEvents)) {
|
||||
socket.logEvents.push({
|
||||
timestamp: new Date(),
|
||||
level,
|
||||
message,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
server/cdk/getVehIds.xml
Normal file
18
server/cdk/getVehIds.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
||||
xmlns:pip="http://www.dmotorworks.com/pip-vehicle">
|
||||
<soapenv:Header/>
|
||||
<soapenv:Body>
|
||||
<pip:getVehIds>
|
||||
<arg0>
|
||||
<password>password</password>
|
||||
<username>username</username>
|
||||
</arg0>
|
||||
<arg1>
|
||||
<id>3PADEALERID</id>
|
||||
</arg1>
|
||||
<arg2>
|
||||
<VIN>5GALRCED7AJ169491</VIN>
|
||||
</arg2>
|
||||
</pip:getVehIds>
|
||||
</soapenv:Body>
|
||||
</soapenv:Envelope>
|
||||
@@ -161,6 +161,13 @@ query QUERY_JOBS_FOR_CDK_EXPORT($id: uuid!) {
|
||||
rate_matd
|
||||
class
|
||||
ca_bc_pvrt
|
||||
plate_no
|
||||
plate_st
|
||||
v_vin
|
||||
v_model_yr
|
||||
v_model_desc
|
||||
v_make_desc
|
||||
v_color
|
||||
ca_customer_gst
|
||||
bodyshop {
|
||||
id
|
||||
|
||||
Reference in New Issue
Block a user