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: active_campaign error handler #2895

Merged
merged 3 commits into from
Dec 12, 2023
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
32 changes: 16 additions & 16 deletions src/v0/destinations/active_campaign/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
feature: 'transformation',
});
if (res.success === false) {
errorHandler(res.response, 'Failed to create new contact');
errorHandler(res, 'Failed to create new contact');
koladilip marked this conversation as resolved.
Show resolved Hide resolved
}
const createdContact = get(res, 'response.data.contact'); // null safe
if (!createdContact) {
errorHandler(res.response, 'Failed to create new contact');
errorHandler(res, 'Failed to create new contact');

Check warning on line 69 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L69

Added line #L69 was not covered by tests
}
return createdContact.id;
};
Expand Down Expand Up @@ -98,7 +98,7 @@
feature: 'transformation',
});
if (res.success === false) {
errorHandler(res.response, 'Failed to fetch already created tags');
errorHandler(res, 'Failed to fetch already created tags');

Check warning on line 101 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L101

Added line #L101 was not covered by tests
}

const storedTags = {};
Expand Down Expand Up @@ -169,7 +169,7 @@
feature: 'transformation',
});
if (res.success === false) {
errorHandler(res.response, 'Failed to create new tag');
errorHandler(res, 'Failed to create new tag');

Check warning on line 172 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L172

Added line #L172 was not covered by tests
// For each tags successfully created the response id is pushed to tagIds
}
if (res.response.status === 201) tagIds.push(res.response.data.tag.id);
Expand Down Expand Up @@ -201,7 +201,7 @@
);
responsesArr.forEach((respItem) => {
if (respItem.success === false)
errorHandler(respItem.response, 'Failed to merge created contact with created tags');
errorHandler(respItem, 'Failed to merge created contact with created tags');

Check warning on line 204 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L204

Added line #L204 was not covered by tests
});
};

Expand All @@ -219,7 +219,7 @@
// Step - 2
// Get the existing field data from dest and store it in responseStaging
// Ref - https://developers.activecampaign.com/reference/retrieve-fields
let endpoint = `${destination.Config.apiUrl}${`${category.fieldEndPoint}?limit=100`}`;
let endpoint = `${destination.Config.apiUrl}${category.fieldEndPoint}?limit=100`;
const requestOptions = {
headers: {
'Api-Token': destination.Config.apiKey,
Expand All @@ -230,7 +230,7 @@
feature: 'transformation',
});
if (res.success === false) {
errorHandler(res.response, 'Failed to get existing field data');
errorHandler(res, 'Failed to get existing field data');

Check warning on line 233 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L233

Added line #L233 was not covered by tests
}
responseStaging.push(res.response.status === 200 ? res.response.data.fields : []);

Expand All @@ -257,7 +257,7 @@
if (resp.success === true && resp.response.status === 200) {
responseStaging.push(resp.response.data.fields);
} else {
errorHandler(resp.response, 'Failed to get existing field data');
errorHandler(resp, 'Failed to get existing field data');

Check warning on line 260 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L260

Added line #L260 was not covered by tests
}
});
}
Expand Down Expand Up @@ -352,7 +352,7 @@
const responses = await Promise.all(promises);
responses.forEach((respItem) => {
if (respItem.success === false) {
errorHandler(respItem.response, 'Failed to map created contact with the list');
errorHandler(respItem, 'Failed to map created contact with the list');

Check warning on line 355 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L355

Added line #L355 was not covered by tests
}
});
};
Expand Down Expand Up @@ -404,11 +404,11 @@
feature: 'transformation',
});
if (res.success === false) {
errorHandler(res.response, 'Failed to retrieve events');
errorHandler(res, 'Failed to retrieve events');

Check warning on line 407 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L407

Added line #L407 was not covered by tests
}

if (res?.response?.status !== 200) {
errorHandler(res.response, 'Unable to create event');
errorHandler(res, 'Unable to create event');

Check warning on line 411 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L411

Added line #L411 was not covered by tests
}

const storedEventsArr = res.response?.data?.eventTrackingEvents;
Expand All @@ -431,11 +431,11 @@
feature: 'transformation',
});
if (res.success === false) {
errorHandler(res.response, 'Failed to create event');
errorHandler(res, 'Failed to create event');

Check warning on line 434 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L434

Added line #L434 was not covered by tests
}

if (res.response.status !== 201) {
errorHandler(res.response, 'Unable to create event');
errorHandler(res, 'Unable to create event');

Check warning on line 438 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L438

Added line #L438 was not covered by tests
}
}
// Previous operations successfull then
Expand Down Expand Up @@ -468,11 +468,11 @@
});

if (res.success === false) {
errorHandler(res.response, 'Failed to retrieve events');
errorHandler(res, 'Failed to retrieve events');

Check warning on line 471 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L471

Added line #L471 was not covered by tests
}

if (res.response.status !== 200) {
errorHandler(res.response, 'Unable to fetch events. Aborting');
errorHandler(res, 'Unable to fetch events. Aborting');

Check warning on line 475 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L475

Added line #L475 was not covered by tests
}

const storedEventsArr = res.response?.data?.eventTrackingEvents;
Expand All @@ -495,7 +495,7 @@
feature: 'transformation',
});
if (res.response?.status !== 201) {
errorHandler(res.response, 'Unable to create event. Aborting');
errorHandler(res, 'Unable to create event. Aborting');

Check warning on line 498 in src/v0/destinations/active_campaign/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/active_campaign/transform.js#L498

Added line #L498 was not covered by tests
}
}

Expand Down
Loading
Loading