From becb4fa54e9093ed69779f54c36864cb9d28d321 Mon Sep 17 00:00:00 2001 From: Aanshi Lahoti <110057617+aanshi07@users.noreply.github.com> Date: Fri, 15 Nov 2024 22:44:16 +0530 Subject: [PATCH] feat: iterable EUDC deleteUsers (#3881) --- src/v0/destinations/iterable/deleteUsers.js | 8 +++-- .../destinations/iterable/deleteUsers/data.ts | 36 +++++++++++++++++++ .../destinations/iterable/network.ts | 17 +++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/v0/destinations/iterable/deleteUsers.js b/src/v0/destinations/iterable/deleteUsers.js index 015a9de9a0..79c4c0affd 100644 --- a/src/v0/destinations/iterable/deleteUsers.js +++ b/src/v0/destinations/iterable/deleteUsers.js @@ -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'); } @@ -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, diff --git a/test/integrations/destinations/iterable/deleteUsers/data.ts b/test/integrations/destinations/iterable/deleteUsers/data.ts index 79d801f4ee..9e7eab1ee1 100644 --- a/test/integrations/destinations/iterable/deleteUsers/data.ts +++ b/test/integrations/destinations/iterable/deleteUsers/data.ts @@ -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', + }, + ], + }, + }, + }, ]; diff --git a/test/integrations/destinations/iterable/network.ts b/test/integrations/destinations/iterable/network.ts index 39544b2647..1cf26dfd4f 100644 --- a/test/integrations/destinations/iterable/network.ts +++ b/test/integrations/destinations/iterable/network.ts @@ -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];