IO-3498 Remove setNewRefreshToken and replace forEach with map
Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -3,7 +3,7 @@ const Dinero = require("dinero.js");
|
||||
|
||||
const apiGqlClient = require("../../graphql-client/graphql-client").client;
|
||||
const queries = require("../../graphql-client/queries");
|
||||
const { refresh: refreshOauthToken, setNewRefreshToken } = require("./qbo-callback");
|
||||
const { refresh: refreshOauthToken } = require("./qbo-callback");
|
||||
const OAuthClient = require("intuit-oauth");
|
||||
const moment = require("moment-timezone");
|
||||
const {
|
||||
@@ -246,7 +246,7 @@ async function InsertPayment(oauthClient, qbo_realmId, req, payment, parentRef)
|
||||
bodyshopid: payment.job.shopid,
|
||||
email: req.user.email
|
||||
});
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
|
||||
if (result.status >= 400) {
|
||||
throw new Error(JSON.stringify(result.json.Fault));
|
||||
}
|
||||
@@ -292,7 +292,6 @@ async function QueryMetaData(oauthClient, qbo_realmId, req, ro_number, isCreditM
|
||||
bodyshopid,
|
||||
email: req.user.email
|
||||
});
|
||||
setNewRefreshToken(req.user.email, paymentMethods);
|
||||
|
||||
// const classes = await oauthClient.makeApiCall({
|
||||
// url: urlBuilder(qbo_realmId, "query", `select * From Class`),
|
||||
@@ -302,11 +301,9 @@ async function QueryMetaData(oauthClient, qbo_realmId, req, ro_number, isCreditM
|
||||
// },
|
||||
// });
|
||||
|
||||
const paymentMethodMapping = {};
|
||||
|
||||
paymentMethods.json?.QueryResponse?.PaymentMethod?.forEach((t) => {
|
||||
paymentMethodMapping[t.Name] = t.Id;
|
||||
});
|
||||
const paymentMethodMapping = Object.fromEntries(
|
||||
(paymentMethods.json?.QueryResponse?.PaymentMethod || []).map((t) => [t.Name, t.Id])
|
||||
);
|
||||
|
||||
// const accountMapping = {};
|
||||
|
||||
@@ -355,18 +352,10 @@ async function QueryMetaData(oauthClient, qbo_realmId, req, ro_number, isCreditM
|
||||
bodyshopid,
|
||||
email: req.user.email
|
||||
});
|
||||
setNewRefreshToken(req.user.email, items);
|
||||
|
||||
const itemMapping = {};
|
||||
const taxCodeMapping = Object.fromEntries((taxCodes.json?.QueryResponse?.TaxCode || []).map((t) => [t.Name, t.Id]));
|
||||
|
||||
items.json?.QueryResponse?.Item?.forEach((t) => {
|
||||
itemMapping[t.Name] = t.Id;
|
||||
});
|
||||
const taxCodeMapping = {};
|
||||
|
||||
taxCodes.json?.QueryResponse?.TaxCode?.forEach((t) => {
|
||||
taxCodeMapping[t.Name] = t.Id;
|
||||
});
|
||||
const itemMapping = Object.fromEntries((items.json?.QueryResponse?.Item || []).map((item) => [item.Name, item.Id]));
|
||||
|
||||
ret = {
|
||||
...ret,
|
||||
@@ -456,7 +445,7 @@ async function InsertCreditMemo(oauthClient, qbo_realmId, req, payment, parentRe
|
||||
bodyshopid: req.user.bodyshopid,
|
||||
email: req.user.email
|
||||
});
|
||||
setNewRefreshToken(req.user.email, result);
|
||||
|
||||
if (result.status >= 400) {
|
||||
throw new Error(JSON.stringify(result.json.Fault));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user