Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/54 support sender profile csclsroz 173 #1258

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/MetadataTypeDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import query from './metadataTypes/definitions/Query.definition.js';
import role from './metadataTypes/definitions/Role.definition.js';
import script from './metadataTypes/definitions/Script.definition.js';
import sendClassification from './metadataTypes/definitions/SendClassification.definition.js';
import senderProfile from './metadataTypes/definitions/SenderProfile.definition.js';
import transactionalEmail from './metadataTypes/definitions/TransactionalEmail.definition.js';
import transactionalPush from './metadataTypes/definitions/TransactionalPush.definition.js';
import transactionalSMS from './metadataTypes/definitions/TransactionalSMS.definition.js';
Expand Down Expand Up @@ -69,6 +70,7 @@ export default {
role,
script,
sendClassification,
senderProfile,
transactionalEmail,
transactionalPush,
transactionalSMS,
Expand Down
2 changes: 2 additions & 0 deletions lib/MetadataTypeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import query from './metadataTypes/Query.js';
import role from './metadataTypes/Role.js';
import script from './metadataTypes/Script.js';
import sendClassification from './metadataTypes/SendClassification.js';
import senderProfile from './metadataTypes/SenderProfile.js';
import transactionalEmail from './metadataTypes/TransactionalEmail.js';
import transactionalPush from './metadataTypes/TransactionalPush.js';
import transactionalSMS from './metadataTypes/TransactionalSMS.js';
Expand Down Expand Up @@ -69,6 +70,7 @@ export default {
role,
script,
sendClassification,
senderProfile,
transactionalEmail,
transactionalPush,
transactionalSMS,
Expand Down
115 changes: 115 additions & 0 deletions lib/metadataTypes/SenderProfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
'use strict';

import MetadataType from './MetadataType.js';
import { Util } from '../util/util.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
*/

/**
* SenderProfile MetadataType
*
* @augments MetadataType
*/
class SenderProfile 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} [_] unused parameter
* @param {void} [__] unused parameter
* @param {void} [___] unused parameter
* @param {string} [key] customer key of single item to retrieve
* @returns {Promise.<MetadataTypeMapObj>} Promise of metadata
*/
static retrieve(retrieveDir, _, __, ___, key) {
/** @type {SoapRequestParams} */
let requestParams = null;
if (key) {
requestParams = {
filter: {
leftOperand: 'CustomerKey',
operator: 'equals',
rightOperand: key,
},
};
}
return super.retrieveSOAP(retrieveDir, null, requestParams);
}
/**
* Updates a single item
*
* @param {MetadataTypeItem} metadataItem a single item
* @returns {Promise} Promise
*/
static update(metadataItem) {
return super.updateSOAP(metadataItem);
}

/**
* Creates a single item
*
* @param {MetadataTypeItem} metadataItem a single item
* @returns {Promise} Promise
*/
static create(metadataItem) {
return super.createSOAP(metadataItem);
}

/**
* Delete a metadata item from the specified business unit
*
* @param {string} customerKey Identifier of data extension
* @returns {Promise.<boolean>} deletion success status
*/
static deleteByKey(customerKey) {
return super.deleteByKeySOAP(customerKey);
}

/**
* prepares a single item for deployment
*
* @param {MetadataTypeItem} metadata a single query activity
* @returns {Promise.<MetadataTypeItem>} Promise
*/
static async preDeployTasks(metadata) {
if (
metadata.UseDefaultRMMRules &&
(metadata.AutoForwardToEmailAddress !== '' || metadata.AutoForwardToName !== '')
) {
Util.logger.warn(
` - ${this.definition.type} ${metadata[this.definition.nameField]} (${
metadata[this.definition.keyField]
}): AutoForwardToEmailAddress and AutoForwardToName will be ignored because UseDefaultRMMRules is set to true; setting UseDefaultRMMRules to false`
);
metadata.UseDefaultRMMRules = false;
} else if (
!metadata.UseDefaultRMMRules &&
(metadata.AutoForwardToEmailAddress === '' || metadata.AutoForwardToName === '')
) {
Util.logger.warn(
` - ${this.definition.type} ${metadata[this.definition.nameField]} (${
metadata[this.definition.keyField]
}): AutoForwardToEmailAddress and AutoForwardToName are required when UseDefaultRMMRules is set to false; setting UseDefaultRMMRules to true`
);
metadata.UseDefaultRMMRules = true;
}
return metadata;
}
}

// Assign definition & cache to static attributes
import MetadataTypeDefinitions from '../MetadataTypeDefinitions.js';
SenderProfile.definition = MetadataTypeDefinitions.senderProfile;

export default SenderProfile;
184 changes: 184 additions & 0 deletions lib/metadataTypes/definitions/SenderProfile.definition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
export default {
bodyIteratorField: 'Results',
dependencies: [],
filter: {},
hasExtended: false,
idField: 'ObjectID',
keyIsFixed: false,
keyField: 'CustomerKey',
nameField: 'Name',
createdDateField: 'CreatedDate',
createdNameField: null,
lastmodDateField: 'ModifiedDate',
lastmodNameField: null,
restPagination: false,
type: 'senderProfile',
typeDescription: 'Specifies the From information for a send in a central location',
typeRetrieveByDefault: false,
typeName: 'Sender Profile',
fields: {
'Client.ID': {
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
CreatedDate: {
isCreateable: false,
isUpdateable: false,
retrieving: true,
template: false,
},
ModifiedDate: {
isCreateable: false,
isUpdateable: false,
retrieving: true,
template: false,
},
CustomerKey: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
ObjectID: {
isCreateable: false,
isUpdateable: true,
retrieving: true,
template: false,
},
Name: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
Description: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
PartnerKey: {
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
PartnerProperties: {
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},

AutoForwardToEmailAddress: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
AutoForwardToName: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
AutoForwardTriggeredSend: {
// not supported
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
AutoReply: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
AutoReplyTriggeredSend: {
// not supported
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
DataRetentionPeriodLength: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
DataRetentionPeriodUnitOfMeasure: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
DirectForward: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
FromAddress: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
FromName: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
ID: {
// not supported
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
ReplyManagementRuleSet: {
// not supported
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
ReplyToAddress: {
// not supported
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
ReplyToDisplayName: {
// not supported
isCreateable: false,
isUpdateable: false,
retrieving: false,
template: false,
},
SenderHeaderEmailAddress: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
SenderHeaderName: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
UseDefaultRMMRules: {
isCreateable: true,
isUpdateable: true,
retrieving: true,
template: true,
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"CustomerKey": "testExisting_senderProfile",
"Name": "testExisting_senderProfile",
"Description": "updated via deploy",
"FromName": "Jörn Berkefeld",
"FromAddress": "joern.berkefeld@accenture.com",
"UseDefaultRMMRules": false,
"AutoForwardToEmailAddress": "joern.berkefeld@accenture.com",
"AutoForwardToName": "Jörn Berkefeld",
"DirectForward": false,
"AutoReply": false,
"SenderHeaderEmailAddress": "",
"SenderHeaderName": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"CustomerKey": "testNew_senderProfile",
"Name": "testNew_senderProfile",
"Description": "created on deploy",
"FromName": "Jörn Berkefeld",
"FromAddress": "joern.berkefeld@accenture.com",
"UseDefaultRMMRules": false,
"AutoForwardToEmailAddress": "joern.berkefeld@accenture.com",
"AutoForwardToName": "Jörn Berkefeld",
"DirectForward": false,
"AutoReply": false,
"SenderHeaderEmailAddress": "",
"SenderHeaderName": ""
}
14 changes: 14 additions & 0 deletions test/resources/9999999/senderProfile/build-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"AutoForwardToEmailAddress": "",
"AutoForwardToName": "",
"AutoReply": false,
"CustomerKey": "testTemplated_senderProfile",
"Description": "Send from joern.berkefeld@accenture.com",
"DirectForward": false,
"FromAddress": "joern.berkefeld@accenture.com",
"FromName": "Jörn Berkefeld",
"Name": "testTemplated_senderProfile",
"SenderHeaderEmailAddress": "",
"SenderHeaderName": "",
"UseDefaultRMMRules": true
}
Loading
Loading