Skip to content

Commit

Permalink
fix: convert to registry pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Dec 3, 2024
1 parent f11d7eb commit 909cad0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/v1/destinations/iterable/networkHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ const { BULK_ENDPOINTS } = require('../../../v0/destinations/iterable/config');
const { CommonStrategy } = require('./commonStrategy');
const { TrackIdentifyStrategy } = require('./trackIdentifyStrategy');

const strategyRegistry = {
[TrackIdentifyStrategy.name]: new TrackIdentifyStrategy(),
[CommonStrategy.name]: new CommonStrategy(),
};

const getResponseStrategy = (endpoint) => {
if (BULK_ENDPOINTS.some((path) => endpoint.includes(path))) {
return new TrackIdentifyStrategy();
return strategyRegistry[TrackIdentifyStrategy.name];
}
return new CommonStrategy();
return strategyRegistry[CommonStrategy.name];
};

const responseHandler = (responseParams) => {
Expand Down

0 comments on commit 909cad0

Please sign in to comment.