Skip to content

Commit

Permalink
#732: add delete support for query
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Feb 13, 2023
1 parent 88045e9 commit 2792dfb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/metadataTypes/DataExtensionField.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,11 @@ class DataExtensionField extends MetadataType {
* Delete a data extension from the specified business unit
*
* @param {string} customerKey Identifier of metadata
* @param {void} _ unused
* @param {boolean} [handleOutside] if the API reponse is irregular this allows you to handle it outside of this generic method
* @returns {boolean} deletion success flag
*/
static async deleteByKeySOAP(customerKey, handleOutside) {
static async deleteByKeySOAP(customerKey, _, handleOutside) {
const [deKey, fieldKey] = customerKey.split('.');
customerKey = `[${deKey}].[${fieldKey}]`;

Expand Down
6 changes: 4 additions & 2 deletions lib/metadataTypes/MetadataType.js
Original file line number Diff line number Diff line change
Expand Up @@ -1611,15 +1611,17 @@ class MetadataType {
* Delete a data extension from the specified business unit
*
* @param {string} customerKey Identifier of metadata
* @param {string} [overrideType] can be used if the API type differs from the otherwise used type identifier
* @param {boolean} [handleOutside] if the API reponse is irregular this allows you to handle it outside of this generic method
* @returns {boolean} deletion success flag
*/
static async deleteByKeySOAP(customerKey, handleOutside) {
static async deleteByKeySOAP(customerKey, overrideType, handleOutside) {
const keyObj = {};
keyObj[this.definition.keyField] = customerKey;
try {
this.client.soap.delete(
this.definition.type.charAt(0).toUpperCase() + this.definition.type.slice(1),
overrideType ||
this.definition.type.charAt(0).toUpperCase() + this.definition.type.slice(1),
keyObj,
null
);
Expand Down
9 changes: 9 additions & 0 deletions lib/metadataTypes/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ class Query extends MetadataType {
return errors.map((msg) => msg.split('Error saving the Query field.').join(''));
}
}
/**
* Delete a metadata item from the specified business unit
*
* @param {string} customerKey Identifier of data extension
* @returns {boolean} deletion success status
*/
static deleteByKey(customerKey) {
return super.deleteByKeySOAP(customerKey, 'QueryDefinition');
}
}

// Assign definition & cache to static attributes
Expand Down

0 comments on commit 2792dfb

Please sign in to comment.