IO-3239 QBO Logging and integration log schema changes.
This commit is contained in:
@@ -233,6 +233,15 @@ async function QueryInsuranceCo(oauthClient, qbo_realmId, req, job) {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "QueryCustomer",
|
||||
status: result.response?.status,
|
||||
bodyshopid: job.shopid,
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
return (
|
||||
result.json &&
|
||||
@@ -279,6 +288,15 @@ async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) {
|
||||
},
|
||||
body: JSON.stringify(Customer)
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "InsertCustomer",
|
||||
status: result.response.status,
|
||||
bodyshopid: job.shopid,
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
return result && result.json.Customer;
|
||||
} catch (error) {
|
||||
@@ -305,6 +323,15 @@ async function QueryOwner(oauthClient, qbo_realmId, req, job, isThreeTier, paren
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "QueryCustomer",
|
||||
status: result.response?.status,
|
||||
bodyshopid: job.shopid,
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
return (
|
||||
result.json &&
|
||||
@@ -347,6 +374,15 @@ async function InsertOwner(oauthClient, qbo_realmId, req, job, isThreeTier, pare
|
||||
},
|
||||
body: JSON.stringify(Customer)
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "InsertCustomer",
|
||||
status: result.response?.status,
|
||||
bodyshopid: job.shopid,
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
return result && result.json.Customer;
|
||||
} catch (error) {
|
||||
@@ -372,6 +408,15 @@ async function QueryJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "QueryCustomer",
|
||||
status: result.response?.status,
|
||||
bodyshopid: job.shopid,
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
return (
|
||||
result.json &&
|
||||
@@ -411,6 +456,15 @@ async function InsertJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
},
|
||||
body: JSON.stringify(Customer)
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "InsertCustomer",
|
||||
status: result.response?.status,
|
||||
bodyshopid: job.shopid,
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
return result && result.json.Customer;
|
||||
} catch (error) {
|
||||
@@ -424,7 +478,7 @@ async function InsertJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
|
||||
exports.InsertJob = InsertJob;
|
||||
|
||||
async function QueryMetaData(oauthClient, qbo_realmId, req) {
|
||||
async function QueryMetaData(oauthClient, qbo_realmId, req, bodyshopid) {
|
||||
const items = await oauthClient.makeApiCall({
|
||||
url: urlBuilder(qbo_realmId, "query", `select * From Item where active=true maxresults 1000`),
|
||||
method: "POST",
|
||||
@@ -432,6 +486,14 @@ async function QueryMetaData(oauthClient, qbo_realmId, req) {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "QueryItems",
|
||||
status: items.response?.status,
|
||||
bodyshopid,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, items);
|
||||
const taxCodes = await oauthClient.makeApiCall({
|
||||
url: urlBuilder(qbo_realmId, "query", `select * From TaxCode where active=true`),
|
||||
@@ -440,7 +502,14 @@ async function QueryMetaData(oauthClient, qbo_realmId, req) {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "QueryTaxCodes",
|
||||
status: taxCodes.response?.status,
|
||||
bodyshopid,
|
||||
email: req.user.email
|
||||
})
|
||||
const classes = await oauthClient.makeApiCall({
|
||||
url: urlBuilder(qbo_realmId, "query", `select * From Class`),
|
||||
method: "POST",
|
||||
@@ -448,7 +517,14 @@ async function QueryMetaData(oauthClient, qbo_realmId, req) {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "QueryClasses",
|
||||
status: classes.response?.status,
|
||||
bodyshopid,
|
||||
email: req.user.email
|
||||
})
|
||||
const taxCodeMapping = {};
|
||||
|
||||
taxCodes.json &&
|
||||
@@ -483,7 +559,7 @@ async function QueryMetaData(oauthClient, qbo_realmId, req) {
|
||||
}
|
||||
|
||||
async function InsertInvoice(oauthClient, qbo_realmId, req, job, bodyshop, parentTierRef) {
|
||||
const { items, taxCodes, classes } = await QueryMetaData(oauthClient, qbo_realmId, req);
|
||||
const { items, taxCodes, classes } = await QueryMetaData(oauthClient, qbo_realmId, req, job.shopid);
|
||||
const InvoiceLineAdd = CreateInvoiceLines({
|
||||
bodyshop,
|
||||
jobs_by_pk: job,
|
||||
@@ -573,6 +649,15 @@ async function InsertInvoice(oauthClient, qbo_realmId, req, job, bodyshop, paren
|
||||
},
|
||||
body: JSON.stringify(invoiceObj)
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "InsertInvoice",
|
||||
status: result.status,
|
||||
bodyshopid: job.shopid,
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
return result && result.json && result.json.Invoice;
|
||||
} catch (error) {
|
||||
@@ -596,7 +681,7 @@ async function InsertInvoiceMultiPayerInvoice(
|
||||
payer,
|
||||
suffix
|
||||
) {
|
||||
const { items, taxCodes, classes } = await QueryMetaData(oauthClient, qbo_realmId, req);
|
||||
const { items, taxCodes, classes } = await QueryMetaData(oauthClient, qbo_realmId, req, job.shopid);
|
||||
const InvoiceLineAdd = createMultiQbPayerLines({
|
||||
bodyshop,
|
||||
jobs_by_pk: job,
|
||||
@@ -689,6 +774,15 @@ async function InsertInvoiceMultiPayerInvoice(
|
||||
},
|
||||
body: JSON.stringify(invoiceObj)
|
||||
});
|
||||
logger.LogIntegrationCall({
|
||||
platform: "QBO",
|
||||
method: "POST",
|
||||
name: "InsertInvoice",
|
||||
status: result.response.status,
|
||||
bodyshopid: job.shopid,
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
})
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
return result && result.json && result.json.Invoice;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user