Skip to content

Commit

Permalink
#889: enable DELETE with new custom keyField
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed May 26, 2023
1 parent e5fff96 commit cc01898
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4019,7 +4019,7 @@ MobileKeyword MetadataType
* [.postCreateTasks(metadataEntry, apiResponse)](#MobileKeyword.postCreateTasks) ⇒ <code>void</code>
* [.postUpdateTasks(metadataEntry, apiResponse)](#MobileKeyword.postUpdateTasks) ⇒ <code>void</code>
* [._mergeCode(metadata, deployDir, [templateName])](#MobileKeyword._mergeCode) ⇒ <code>Promise.&lt;string&gt;</code>
* [.deleteByKey(id)](#MobileKeyword.deleteByKey) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.deleteByKey(key)](#MobileKeyword.deleteByKey) ⇒ <code>Promise.&lt;boolean&gt;</code>
* [.postDeleteTasks(customerKey)](#MobileKeyword.postDeleteTasks) ⇒ <code>void</code>
* [.getFilesToCommit(keyArr)](#MobileKeyword.getFilesToCommit) ⇒ <code>Array.&lt;string&gt;</code>

Expand Down Expand Up @@ -4224,15 +4224,15 @@ helper for [preDeployTasks](preDeployTasks) that loads extracted code content ba

<a name="MobileKeyword.deleteByKey"></a>

### MobileKeyword.deleteByKey(id) ⇒ <code>Promise.&lt;boolean&gt;</code>
### MobileKeyword.deleteByKey(key) ⇒ <code>Promise.&lt;boolean&gt;</code>
Delete a metadata item from the specified business unit

**Kind**: static method of [<code>MobileKeyword</code>](#MobileKeyword)
**Returns**: <code>Promise.&lt;boolean&gt;</code> - deletion success status

| Param | Type | Description |
| --- | --- | --- |
| id | <code>string</code> | Identifier of item |
| key | <code>string</code> | Identifier of item |

<a name="MobileKeyword.postDeleteTasks"></a>

Expand Down
15 changes: 11 additions & 4 deletions lib/metadataTypes/MobileKeyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,22 @@ class MobileKeyword extends MetadataType {
/**
* Delete a metadata item from the specified business unit
*
* @param {string} id Identifier of item
* @param {string} key Identifier of item
* @returns {Promise.<boolean>} deletion success status
*/
static async deleteByKey(id) {
static async deleteByKey(key) {
// get id from cache
const { metadata } = await this.retrieveForCache(key);
if (!metadata[key]) {
Util.logger.error(`Could not find ${this.definition.type} with key ${key}.`);
return false;
}
const id = metadata[key][this.definition.idField];
// execute delete
Util.logger.info(
' - Note: As long as the provided API id once existed, you will not see an error even if the mobileKeyword is already deleted.'
' - Note: As long as the provided API key once existed, you will not see an error even if the mobileKeyword is already deleted.'
);
return super.deleteByKeyREST('/legacy/v1/beta/mobile/keyword/' + id, id, false);
return super.deleteByKeyREST('/legacy/v1/beta/mobile/keyword/' + id, key, false);
}

/**
Expand Down

0 comments on commit cc01898

Please sign in to comment.