Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: (marketo)- remove duplicate responseHandler from util and refactor #1557

Merged
merged 5 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions v0/destinations/marketo/networkHandler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { TRANSFORMER_METRIC } = require("../../util/constant");
const v0Utils = require("../../util");
const { marketoResponseHandler } = require("./util");
const {
proxyRequest,
Expand All @@ -9,14 +10,17 @@ const {
} = require("../../../adapters/utils/networkUtils");

// eslint-disable-next-line no-unused-vars
const responseHandler = (destinationResponse, _dest) => {
const responseHandler = (destinationResponse, destType) => {
const message = `[Marketo Response Handler] - Request Processed Successfully`;
const { status } = destinationResponse;
const authCache = v0Utils.getDestAuthCacheInstance(destType);
// check for marketo application level failures
marketoResponseHandler(
destinationResponse,
"during Marketo Response Handling",
TRANSFORMER_METRIC.TRANSFORMER_STAGE.RESPONSE_TRANSFORM
TRANSFORMER_METRIC.TRANSFORMER_STAGE.RESPONSE_TRANSFORM,
destinationResponse?.rudderJobMetadata,
authCache
);
// else successfully return status, message and original destination response
return {
Expand Down
2 changes: 1 addition & 1 deletion v0/destinations/marketo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ function processMetadataForRouter(output) {
const { metadata, destination } = output;
const clonedMetadata = cloneDeep(metadata);
clonedMetadata.forEach(metadataElement => {
metadataElement.destInfo = { authKey: destination.ID };
metadataElement.destInfo = { authKey: destination?.ID };
});
return clonedMetadata;
}
Expand Down
30 changes: 0 additions & 30 deletions v0/destinations/marketo/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const {
} = require("../../../adapters/utils/networkUtils");
const { isHttpStatusSuccess } = require("../../util/index");
const { TRANSFORMER_METRIC } = require("../../util/constant");
const v0Utils = require("../../util");
const { ApiError } = require("../../util/errors");

/**
Expand Down Expand Up @@ -156,27 +155,6 @@ const sendPostRequest = async (url, data, options) => {
return processedResponse;
};

// eslint-disable-next-line no-unused-vars
const responseHandler = (destinationResponse, destType) => {
const message = `[Marketo Response Handler] - Request Processed Successfully`;
const { status } = destinationResponse;
const authCache = v0Utils.getDestAuthCacheInstance(destType);
// check for marketo application level failures
marketoResponseHandler(
destinationResponse,
"during Marketo Response Handling",
TRANSFORMER_METRIC.TRANSFORMER_STAGE.RESPONSE_TRANSFORM,
destinationResponse?.rudderJobMetadata,
authCache
);
// else successfully return status, message and original destination response
return {
status,
message,
destinationResponse
};
};

const getResponseHandlerData = (
clientResponse,
lookupMessage,
Expand All @@ -192,17 +170,9 @@ const getResponseHandlerData = (
);
};

const networkHandler = function() {
this.responseHandler = responseHandler;
this.proxy = proxyRequest;
this.prepareProxy = prepareProxyRequest;
this.processAxiosResponse = processAxiosResponse;
};

module.exports = {
marketoResponseHandler,
sendGetRequest,
sendPostRequest,
networkHandler,
getResponseHandlerData
};