-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ok
- Loading branch information
Showing
4 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Triggers SFMC contact deletion via API | ||
* @param {object} tokenData SFMC REST API token | ||
* @param {string[]} contactKeys An array of contact keys deletion should be triggered for | ||
* @returns {object | undefined} | ||
*/ | ||
function deleteContactsByKey(tokenData, contactKeys) { | ||
if (!tokenData || !tokenData.token || !tokenData.restInstanceURL) { | ||
return undefined | ||
} | ||
|
||
if (!contactKeys || contactKeys.length <= 0) { | ||
return undefined | ||
} | ||
|
||
var headerNames = ['Authorization'] | ||
var headerValues = ['Bearer ' + tokenData.token] | ||
var requestData = { | ||
values: contactKeys, | ||
DeleteOperationType: 'ContactAndAttributes' | ||
} | ||
var requestUrl = tokenData.restInstanceURL + '/contacts/v1/contacts/actions/delete?type=keys' | ||
var triggerDelete = HTTP.Post(requestUrl, 'application/json; charset=utf-8', Stringify(requestData), headerNames, headerValues) | ||
|
||
return triggerDelete.Response && triggerDelete.Response[0] | ||
? Platform.Function.ParseJSON(triggerDelete.Response[0]) | ||
: undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters