From d699fbf8ab91cd3275aa990f8dd35a426b96a9f9 Mon Sep 17 00:00:00 2001 From: ItsSudip Date: Fri, 6 Sep 2024 18:55:09 +0530 Subject: [PATCH] feat: add deletion support for record events --- src/v0/destinations/sfmc/transform.js | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/v0/destinations/sfmc/transform.js b/src/v0/destinations/sfmc/transform.js index 84050a13182..9c21b27f0a9 100644 --- a/src/v0/destinations/sfmc/transform.js +++ b/src/v0/destinations/sfmc/transform.js @@ -329,6 +329,46 @@ const retlResponseBuilder = async (message, destination, metadata) => { externalKey, token, }); + } else if (action === 'delete') { + let data = `\n + \n + ACCESS_TOKEN\n + \n + \n + \n + \n + CUSTOMER_KEY\n + \n + \n + FIELD_NAME\n + FIELD_VALUE\n + \n + \n + \n + \n + \n + `; + data = data.replace('ACCESS_TOKEN', token); + data = data.replace('CUSTOMER_KEY', externalKey); + data = data.replace('FIELD_NAME', destinationExternalId); + data = data.replace('FIELD_VALUE', message.fields[identifierType]); + const response = defaultRequestConfig(); + response.method = defaultPostRequestConfig.requestMethod; + response.endpoint = `https://${subDomain}.soap.marketingcloudapis.com/Service.asmx`; + response.headers = { + soapaction: 'Delete', + 'Content-Type': 'text/xml; charset="UTF-8"', + }; + response.body.XML = { + payload: data, + }; + return response; } }