Skip to content

Commit

Permalink
feat: iterable EUDC deleteUsers (#3881)
Browse files Browse the repository at this point in the history
  • Loading branch information
aanshi07 authored Nov 15, 2024
1 parent 3d7db73 commit becb4fa
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/v0/destinations/iterable/deleteUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ const { getDynamicErrorType } = require('../../../adapters/utils/networkUtils');
const { executeCommonValidations } = require('../../util/regulation-api');
const tags = require('../../util/tags');
const { JSON_MIME_TYPE } = require('../../util/constant');
const { constructEndpoint } = require('./config');

// Ref-> https://developers.intercom.com/intercom-api-reference/v1.3/reference/permanently-delete-a-user
// Ref-> https://support.iterable.com/hc/en-us/articles/360032290032-Deleting-Users
const userDeletionHandler = async (userAttributes, config) => {
if (!config) {
throw new ConfigurationError('Config for deletion not present');
}
const { apiKey } = config;
const { apiKey, dataCenter } = config;
if (!apiKey) {
throw new ConfigurationError('api key for deletion not present');
}
Expand All @@ -26,7 +27,8 @@ const userDeletionHandler = async (userAttributes, config) => {
const failedUserDeletions = [];
await Promise.all(
validUserIds.map(async (uId) => {
const url = `https://api.iterable.com/api/users/byUserId/${uId}`;
const endpointCategory = { endpoint: `users/byUserId/${uId}` };
const url = constructEndpoint(dataCenter, endpointCategory);
const requestOptions = {
headers: {
'Content-Type': JSON_MIME_TYPE,
Expand Down
36 changes: 36 additions & 0 deletions test/integrations/destinations/iterable/deleteUsers/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,40 @@ export const data = [
},
},
},
{
name: destType,
description: 'Test 5: should pass when dataCenter is selected as EUDC',
feature: 'userDeletion',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
destType: destType.toUpperCase(),
userAttributes: [
{
userId: 'rudder7',
},
],
config: {
apiKey: 'dummyApiKey',
dataCenter: 'EUDC',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
statusCode: 200,
status: 'successful',
},
],
},
},
},
];
17 changes: 17 additions & 0 deletions test/integrations/destinations/iterable/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,22 @@ const deleteNwData = [
status: 200,
},
},
{
httpReq: {
method: 'delete',
url: 'https://api.eu.iterable.com/api/users/byUserId/rudder7',
headers: {
api_key: 'dummyApiKey',
},
},
httpRes: {
data: {
msg: 'All users associated with rudder7 were successfully deleted',
code: 'Success',
params: null,
},
status: 200,
},
},
];
export const networkCallsData = [...deleteNwData];

0 comments on commit becb4fa

Please sign in to comment.