From ebffd18e6afcc37a1686163a09dd62c26251174f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Mon, 15 Apr 2024 18:59:43 +0200 Subject: [PATCH] #60: basic retrieve-support for deliveryProfile --- lib/MetadataTypeDefinitions.js | 2 + lib/MetadataTypeInfo.js | 2 + lib/metadataTypes/DeliveryProfile.js | 47 +++++++++++++++ .../definitions/DeliveryProfile.definition.js | 57 +++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 lib/metadataTypes/DeliveryProfile.js create mode 100644 lib/metadataTypes/definitions/DeliveryProfile.definition.js diff --git a/lib/MetadataTypeDefinitions.js b/lib/MetadataTypeDefinitions.js index 86f51d0ae..4acbcaf6d 100644 --- a/lib/MetadataTypeDefinitions.js +++ b/lib/MetadataTypeDefinitions.js @@ -11,6 +11,7 @@ import dataExtensionField from './metadataTypes/definitions/DataExtensionField.d import dataExtensionTemplate from './metadataTypes/definitions/DataExtensionTemplate.definition.js'; import dataExtract from './metadataTypes/definitions/DataExtract.definition.js'; import dataExtractType from './metadataTypes/definitions/DataExtractType.definition.js'; +import deliveryProfile from './metadataTypes/definitions/DeliveryProfile.definition.js'; import discovery from './metadataTypes/definitions/Discovery.definition.js'; import email from './metadataTypes/definitions/Email.definition.js'; import emailSend from './metadataTypes/definitions/EmailSend.definition.js'; @@ -53,6 +54,7 @@ export default { dataExtensionTemplate, dataExtract, dataExtractType, + deliveryProfile, discovery, email, emailSend, diff --git a/lib/MetadataTypeInfo.js b/lib/MetadataTypeInfo.js index b0be83eaa..b66222cff 100644 --- a/lib/MetadataTypeInfo.js +++ b/lib/MetadataTypeInfo.js @@ -11,6 +11,7 @@ import dataExtensionField from './metadataTypes/DataExtensionField.js'; import dataExtensionTemplate from './metadataTypes/DataExtensionTemplate.js'; import dataExtract from './metadataTypes/DataExtract.js'; import dataExtractType from './metadataTypes/DataExtractType.js'; +import deliveryProfile from './metadataTypes/DeliveryProfile.js'; import discovery from './metadataTypes/Discovery.js'; import email from './metadataTypes/Email.js'; import emailSend from './metadataTypes/EmailSend.js'; @@ -52,6 +53,7 @@ export default { dataExtensionTemplate, dataExtract, dataExtractType, + deliveryProfile, discovery, email, emailSend, diff --git a/lib/metadataTypes/DeliveryProfile.js b/lib/metadataTypes/DeliveryProfile.js new file mode 100644 index 000000000..2c94f7ebf --- /dev/null +++ b/lib/metadataTypes/DeliveryProfile.js @@ -0,0 +1,47 @@ +'use strict'; + +import MetadataType from './MetadataType.js'; + +/** + * @typedef {import('../../types/mcdev.d.js').BuObject} BuObject + * @typedef {import('../../types/mcdev.d.js').CodeExtract} CodeExtract + * @typedef {import('../../types/mcdev.d.js').CodeExtractItem} CodeExtractItem + * @typedef {import('../../types/mcdev.d.js').MetadataTypeItem} MetadataTypeItem + * @typedef {import('../../types/mcdev.d.js').MetadataTypeItemDiff} MetadataTypeItemDiff + * @typedef {import('../../types/mcdev.d.js').MetadataTypeItemObj} MetadataTypeItemObj + * @typedef {import('../../types/mcdev.d.js').MetadataTypeMap} MetadataTypeMap + * @typedef {import('../../types/mcdev.d.js').MetadataTypeMapObj} MetadataTypeMapObj + * @typedef {import('../../types/mcdev.d.js').SoapRequestParams} SoapRequestParams + * @typedef {import('../../types/mcdev.d.js').TemplateMap} TemplateMap + */ + +/** + * DeliveryProfile MetadataType + * + * @augments MetadataType + */ +class DeliveryProfile extends MetadataType { + /** + * Retrieves SOAP based metadata of metadata type into local filesystem. executes callback with retrieved metadata + * + * @param {string} retrieveDir Directory where retrieved metadata directory will be saved + * @param {void | string[]} [_] not used + * @param {void | string[]} [__] unused parameter + * @param {string} [key] customer key of single item to retrieve + * @returns {Promise.} Promise of metadata + */ + static retrieve(retrieveDir, _, __, key) { + return super.retrieveREST( + retrieveDir, + '/legacy/v1/beta/messaging/deliverypolicy/', + null, + key + ); + } +} + +// Assign definition to static attributes +import MetadataTypeDefinitions from '../MetadataTypeDefinitions.js'; +DeliveryProfile.definition = MetadataTypeDefinitions.deliveryProfile; + +export default DeliveryProfile; diff --git a/lib/metadataTypes/definitions/DeliveryProfile.definition.js b/lib/metadataTypes/definitions/DeliveryProfile.definition.js new file mode 100644 index 000000000..fefbe0059 --- /dev/null +++ b/lib/metadataTypes/definitions/DeliveryProfile.definition.js @@ -0,0 +1,57 @@ +export default { + bodyIteratorField: 'entry', + dependencies: [], + filter: {}, + hasExtended: false, + idField: 'id', + keyField: 'key', + nameField: 'name', + createdDateField: 'createdDate', + createdNameField: null, + lastmodDateField: 'lastUpdated', + lastmodNameField: null, + restPagination: false, + type: 'deliveryProfile', + typeDescription: + 'Delivery profiles specify details such as IP address, domain, header inclusion, and footer; Via API we can only check for their existence but not see any details.', + typeRetrieveByDefault: false, + typeName: 'Delivery Profile', + fields: { + id: { + isCreateable: false, + isUpdateable: false, + retrieving: true, + template: false, + }, + key: { + isCreateable: true, + isUpdateable: true, + retrieving: true, + template: true, + }, + name: { + isCreateable: true, + isUpdateable: true, + retrieving: true, + template: true, + }, + description: { + isCreateable: true, + isUpdateable: true, + retrieving: true, + template: true, + }, + createdDate: { + isCreateable: false, + isUpdateable: false, + retrieving: true, + template: false, + }, + lastUpdated: { + isCreateable: false, + isUpdateable: false, + retrieving: true, + template: false, + }, + }, +};