2020-10-11 09:34:05 -07:00
import {
IExecuteFunctions ,
} from 'n8n-core' ;
import {
IDataObject ,
ILoadOptionsFunctions ,
INodeExecutionData ,
INodePropertyOptions ,
INodeType ,
INodeTypeDescription ,
2021-04-16 09:33:36 -07:00
NodeOperationError ,
2020-10-11 09:34:05 -07:00
} from 'n8n-workflow' ;
import {
awsApiRequestSOAP ,
awsApiRequestSOAPAllItems ,
} from './GenericFunctions' ;
function setParameter ( params : string [ ] , base : string , values : string [ ] ) {
for ( let i = 0 ; i < values . length ; i ++ ) {
2021-02-07 15:02:10 -08:00
params . push ( ` ${ base } . ${ i + 1 } = ${ values [ i ] } ` ) ;
2020-10-11 09:34:05 -07:00
}
}
export class AwsSes implements INodeType {
description : INodeTypeDescription = {
displayName : 'AWS SES' ,
name : 'awsSes' ,
2021-02-07 15:02:10 -08:00
icon : 'file:ses.svg' ,
2020-10-11 09:34:05 -07:00
group : [ 'output' ] ,
version : 1 ,
subtitle : '={{$parameter["operation"] + ": " + $parameter["resource"]}}' ,
description : 'Sends data to AWS SES' ,
defaults : {
name : 'AWS SES' ,
} ,
inputs : [ 'main' ] ,
outputs : [ 'main' ] ,
credentials : [
{
name : 'aws' ,
required : true ,
} ,
] ,
properties : [
{
displayName : 'Resource' ,
name : 'resource' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-10-11 09:34:05 -07:00
options : [
2021-02-07 15:02:10 -08:00
{
name : 'Custom Verification Email' ,
value : 'customVerificationEmail' ,
} ,
2020-10-11 09:34:05 -07:00
{
name : 'Email' ,
value : 'email' ,
} ,
{
name : 'Template' ,
value : 'template' ,
} ,
] ,
default : 'email' ,
} ,
2021-02-07 15:02:10 -08:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-02-07 15:02:10 -08:00
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a new custom verification email template' ,
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete an existing custom verification email template' ,
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get the custom email verification template' ,
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all the existing custom verification email templates for your account' ,
} ,
{
name : 'Send' ,
value : 'send' ,
description : 'Add an email address to the list of identities' ,
} ,
{
name : 'Update' ,
value : 'update' ,
2022-05-06 14:01:25 -07:00
description : 'Update an existing custom verification email template' ,
2021-02-07 15:02:10 -08:00
} ,
] ,
default : 'create' ,
} ,
{
displayName : 'From Email' ,
name : 'fromEmailAddress' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'The email address that the custom verification email is sent from' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
{
displayName : 'Template Name' ,
name : 'templateName' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The name of the custom verification email template' ,
2021-02-07 15:02:10 -08:00
} ,
{
displayName : 'Template Content' ,
name : 'templateContent' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The content of the custom verification email. The total size of the email must be less than 10 MB. The message body may contain HTML' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
{
displayName : 'Template Subject' ,
name : 'templateSubject' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
default : '' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'The subject line of the custom verification email' ,
2021-02-07 15:02:10 -08:00
} ,
{
displayName : 'Success Redirection URL' ,
name : 'successRedirectionURL' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'The URL that the recipient of the verification email is sent to if his or her address is successfully verified' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
{
displayName : 'Failure Redirection URL' ,
name : 'failureRedirectionURL' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'The URL that the recipient of the verification email is sent to if his or her address is not successfully verified' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
{
displayName : 'Email' ,
name : 'email' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'send' ,
] ,
} ,
} ,
default : '' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'The email address to verify' ,
2021-02-07 15:02:10 -08:00
} ,
{
displayName : 'Template Name' ,
name : 'templateName' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'send' ,
] ,
} ,
} ,
default : '' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'The name of the custom verification email template to use when sending the verification email' ,
2021-02-07 15:02:10 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'send' ,
] ,
} ,
} ,
options : [
{
displayName : 'Configuration Set Name' ,
name : 'configurationSetName' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'Name of a configuration set to use when sending the verification email' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
] ,
} ,
{
displayName : 'Template Name' ,
name : 'templateName' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'update' ,
'delete' ,
'get' ,
] ,
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The name of the custom verification email template' ,
2021-02-07 15:02:10 -08:00
} ,
{
displayName : 'Update Fields' ,
name : 'updateFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
options : [
{
displayName : 'Failure Redirection URL' ,
name : 'failureRedirectionURL' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'The URL that the recipient of the verification email is sent to if his or her address is not successfully verified' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
{
displayName : 'From Email' ,
name : 'fromEmailAddress' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'The email address that the custom verification email is sent from' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
{
displayName : 'Success Redirection URL' ,
name : 'successRedirectionURL' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'The URL that the recipient of the verification email is sent to if his or her address is successfully verified' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
{
displayName : 'Template Content' ,
name : 'templateContent' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The content of the custom verification email. The total size of the email must be less than 10 MB. The message body may contain HTML' ,
2021-02-07 15:02:10 -08:00
default : '' ,
} ,
{
displayName : 'Template Subject' ,
name : 'templateSubject' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The subject line of the custom verification email' ,
2021-02-07 15:02:10 -08:00
} ,
] ,
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-02-07 15:02:10 -08:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
2022-05-20 14:47:24 -07:00
typeOptions : {
minValue : 1 ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-02-07 15:02:10 -08:00
default : 20 ,
displayOptions : {
show : {
resource : [
'customVerificationEmail' ,
] ,
operation : [
'getAll' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
} ,
2020-10-11 09:34:05 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-10-11 09:34:05 -07:00
displayOptions : {
show : {
resource : [
'email' ,
] ,
} ,
} ,
options : [
{
name : 'Send' ,
value : 'send' ,
} ,
{
name : 'Send Template' ,
value : 'sendTemplate' ,
} ,
] ,
default : 'send' ,
} ,
{
displayName : 'Is Body HTML' ,
name : 'isBodyHtml' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'send' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'If body is HTML or simple text' ,
2020-10-11 09:34:05 -07:00
} ,
{
displayName : 'Subject' ,
name : 'subject' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'send' ,
] ,
} ,
} ,
default : '' ,
required : true ,
} ,
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'send' ,
] ,
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The message to be sent' ,
2020-10-11 09:34:05 -07:00
required : true ,
} ,
{
displayName : 'From Email' ,
name : 'fromEmail' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'send' ,
] ,
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Email address of the sender' ,
2020-10-11 09:34:05 -07:00
placeholder : 'admin@example.com' ,
default : '' ,
} ,
{
displayName : 'To Addresses' ,
name : 'toAddresses' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'Email addresses of the recipients' ,
2020-10-11 09:34:05 -07:00
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add To Email' ,
} ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'send' ,
] ,
} ,
} ,
placeholder : 'info@example.com' ,
default : [ ] ,
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Template Name or ID' ,
2020-10-11 09:34:05 -07:00
name : 'templateName' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getTemplates' ,
} ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'sendTemplate' ,
] ,
} ,
} ,
default : '' ,
2022-06-03 10:23:49 -07:00
description : 'The ARN of the template to use when sending this email. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>.' ,
2020-10-11 09:34:05 -07:00
} ,
{
displayName : 'From Email' ,
name : 'fromEmail' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'sendTemplate' ,
] ,
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Email address of the sender' ,
2020-10-11 09:34:05 -07:00
placeholder : 'admin@example.com' ,
default : '' ,
} ,
{
displayName : 'To Addresses' ,
name : 'toAddresses' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'Email addresses of the recipients' ,
2020-10-11 09:34:05 -07:00
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add To Email' ,
} ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'sendTemplate' ,
] ,
} ,
} ,
placeholder : 'info@example.com' ,
default : [ ] ,
} ,
{
displayName : 'Template Data' ,
name : 'templateDataUi' ,
type : 'fixedCollection' ,
placeholder : 'Add Data' ,
typeOptions : {
multipleValues : true ,
} ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'sendTemplate' ,
] ,
} ,
} ,
default : { } ,
options : [
{
displayName : 'Data' ,
name : 'templateDataValues' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'email' ,
] ,
operation : [
'send' ,
'sendTemplate' ,
] ,
} ,
} ,
options : [
{
displayName : 'Bcc Addresses' ,
name : 'bccAddresses' ,
type : 'string' ,
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add Bcc Email' ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Bcc Recipients of the email' ,
2020-10-11 09:34:05 -07:00
default : [ ] ,
} ,
{
displayName : 'Cc Addresses' ,
name : 'ccAddresses' ,
type : 'string' ,
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add Cc Email' ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Cc recipients of the email' ,
2020-10-11 09:34:05 -07:00
default : [ ] ,
} ,
{
displayName : 'Configuration Set Name' ,
name : 'configurationSetName' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'Name of the configuration set to use when you send an email using send' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
{
displayName : 'Reply To Addresses' ,
name : 'replyToAddresses' ,
type : 'string' ,
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add Reply To Email' ,
} ,
placeholder : 'Add Reply Address' ,
2022-05-06 14:01:25 -07:00
description : 'Reply-to email address(es) for the message' ,
2020-10-11 09:34:05 -07:00
default : [ ] ,
} ,
{
displayName : 'Return Path' ,
name : 'returnPath' ,
type : 'string' ,
description : 'Email address that bounces and complaints will be forwarded to when feedback forwarding is enabled' ,
default : '' ,
} ,
{
displayName : 'Return Path ARN' ,
name : 'returnPathArn' ,
type : 'string' ,
default : '' ,
description : 'This parameter is used only for sending authorization' ,
} ,
{
displayName : 'Source ARN' ,
name : 'sourceArn' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'This parameter is used only for sending authorization' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
] ,
} ,
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2020-10-11 09:34:05 -07:00
displayOptions : {
show : {
resource : [
'template' ,
] ,
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a template' ,
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a template' ,
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a template' ,
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all templates' ,
} ,
{
name : 'Update' ,
value : 'update' ,
description : 'Update a template' ,
} ,
] ,
default : 'create' ,
} ,
{
displayName : 'Template Name' ,
name : 'templateName' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'template' ,
] ,
operation : [
'update' ,
'create' ,
'get' ,
'delete' ,
] ,
} ,
} ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'The name of the template' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
{
displayName : 'Subject Part' ,
name : 'subjectPart' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'template' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The subject line of the email' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
{
displayName : 'Html Part' ,
name : 'htmlPart' ,
type : 'string' ,
displayOptions : {
show : {
resource : [
'template' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The HTML body of the email' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'template' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
options : [
{
displayName : 'Text Part' ,
name : 'textPart' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'The email body that will be visible to recipients whose email clients do not display HTML' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
] ,
} ,
{
displayName : 'Update Fields' ,
name : 'updateFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'template' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
options : [
{
displayName : 'Text Part' ,
name : 'textPart' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'The email body that will be visible to recipients whose email clients do not display HTML' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
{
displayName : 'Subject Part' ,
name : 'subjectPart' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'The subject line of the email' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
{
displayName : 'Html Part' ,
name : 'htmlPart' ,
type : 'string' ,
2022-05-06 14:01:25 -07:00
description : 'The HTML body of the email' ,
2020-10-11 09:34:05 -07:00
default : '' ,
} ,
] ,
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'template' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2020-10-11 09:34:05 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
2022-05-20 14:47:24 -07:00
typeOptions : {
minValue : 1 ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2020-10-11 09:34:05 -07:00
default : 20 ,
displayOptions : {
show : {
resource : [
'template' ,
] ,
operation : [
'getAll' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
} ,
] ,
} ;
methods = {
loadOptions : {
// Get all the available templates to display them to user so that he can
// select them easily
async getTemplates ( this : ILoadOptionsFunctions ) : Promise < INodePropertyOptions [ ] > {
const returnData : INodePropertyOptions [ ] = [ ] ;
const templates = await awsApiRequestSOAPAllItems . call ( this , 'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member' , 'email' , 'POST' , '/?Action=ListTemplates' ) ;
for ( const template of templates ) {
const templateName = template . Name ;
const templateId = template . Name ;
returnData . push ( {
name : templateName ,
value : templateId ,
} ) ;
}
return returnData ;
2020-10-22 06:46:03 -07:00
} ,
2020-10-11 09:34:05 -07:00
} ,
} ;
async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
const items = this . getInputData ( ) ;
const returnData : IDataObject [ ] = [ ] ;
let responseData ;
const resource = this . getNodeParameter ( 'resource' , 0 ) as string ;
const operation = this . getNodeParameter ( 'operation' , 0 ) as string ;
for ( let i = 0 ; i < items . length ; i ++ ) {
2021-07-19 23:58:54 -07:00
try {
if ( resource === 'customVerificationEmail' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'create' ) {
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const failureRedirectionURL = this . getNodeParameter ( 'failureRedirectionURL' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const email = this . getNodeParameter ( 'fromEmailAddress' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const successRedirectionURL = this . getNodeParameter ( 'successRedirectionURL' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const templateContent = this . getNodeParameter ( 'templateContent' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const templateSubject = this . getNodeParameter ( 'templateSubject' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const params = [
` Action=CreateCustomVerificationEmailTemplate ` ,
` FailureRedirectionURL= ${ failureRedirectionURL } ` ,
` FromEmailAddress= ${ email } ` ,
` SuccessRedirectionURL= ${ successRedirectionURL } ` ,
` TemplateContent= ${ templateContent } ` ,
` TemplateName= ${ templateName } ` ,
` TemplateSubject= ${ templateSubject } ` ,
] ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '' , params . join ( '&' ) ) ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . CreateCustomVerificationEmailTemplateResponse ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( operation === 'delete' ) {
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const params = [
` Action=DeleteCustomVerificationEmailTemplate ` ,
` TemplateName= ${ templateName } ` ,
] ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '' , params . join ( '&' ) ) ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . DeleteCustomVerificationEmailTemplateResponse ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( operation === 'get' ) {
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const params = [
` TemplateName= ${ templateName } ` ,
] ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '/?Action=GetCustomVerificationEmailTemplate&' + params . join ( '&' ) ) ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . GetCustomVerificationEmailTemplateResponse ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( operation === 'getAll' ) {
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const returnAll = this . getNodeParameter ( 'returnAll' , i ) as boolean ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( returnAll === true ) {
responseData = await awsApiRequestSOAPAllItems . call ( this , 'ListCustomVerificationEmailTemplatesResponse.ListCustomVerificationEmailTemplatesResult.CustomVerificationEmailTemplates.member' , 'email' , 'POST' , '/?Action=ListCustomVerificationEmailTemplates' ) ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
} else {
const limit = this . getNodeParameter ( 'limit' , i ) as number ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'GET' , ` /?Action=ListCustomVerificationEmailTemplates&MaxResults= ${ limit } ` ) ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . ListCustomVerificationEmailTemplatesResponse . ListCustomVerificationEmailTemplatesResult . CustomVerificationEmailTemplates . member ;
}
2021-02-07 15:02:10 -08:00
}
2021-07-19 23:58:54 -07:00
if ( operation === 'send' ) {
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const email = this . getNodeParameter ( 'email' , i ) as string [ ] ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) as IDataObject ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const params = [
` Action=SendCustomVerificationEmail ` ,
` TemplateName= ${ templateName } ` ,
` EmailAddress= ${ email } ` ,
] ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . configurationSetName ) {
params . push ( ` ConfigurationSetName= ${ additionalFields . configurationSetName } ` ) ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '' , params . join ( '&' ) ) ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . SendCustomVerificationEmailResponse ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( operation === 'update' ) {
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const updateFields = this . getNodeParameter ( 'updateFields' , i ) as IDataObject ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
const params = [
` Action=UpdateCustomVerificationEmailTemplate ` ,
` TemplateName= ${ templateName } ` ,
] ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( updateFields . FailureRedirectionURL ) {
params . push ( ` FailureRedirectionURL= ${ updateFields . FailureRedirectionURL } ` ) ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( updateFields . email ) {
params . push ( ` FromEmailAddress= ${ updateFields . email } ` ) ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( updateFields . successRedirectionURL ) {
params . push ( ` SuccessRedirectionURL= ${ updateFields . successRedirectionURL } ` ) ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( updateFields . templateContent ) {
params . push ( ` TemplateContent= ${ updateFields . templateContent } ` ) ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( updateFields . templateSubject ) {
params . push ( ` TemplateSubject= ${ updateFields . templateSubject } ` ) ;
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '' , params . join ( '&' ) ) ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
responseData = responseData . UpdateCustomVerificationEmailTemplateResponse ;
}
2021-02-07 15:02:10 -08:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'email' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'send' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const toAddresses = this . getNodeParameter ( 'toAddresses' , i ) as string [ ] ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const message = this . getNodeParameter ( 'body' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const subject = this . getNodeParameter ( 'subject' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const fromEmail = this . getNodeParameter ( 'fromEmail' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const isBodyHtml = this . getNodeParameter ( 'isBodyHtml' , i ) as boolean ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) as IDataObject ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const params = [
` Message.Subject.Data= ${ subject } ` ,
` Source= ${ fromEmail } ` ,
] ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( isBodyHtml ) {
2021-08-10 05:51:58 -07:00
params . push ( ` Message.Body.Html.Data= ${ encodeURIComponent ( message ) } ` ) ;
params . push ( ` Message.Body.Html.Charset=UTF-8 ` ) ;
2021-07-19 23:58:54 -07:00
} else {
2021-08-10 05:51:58 -07:00
params . push ( ` Message.Body.Text.Data= ${ encodeURIComponent ( message ) } ` ) ;
2021-07-19 23:58:54 -07:00
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( toAddresses . length ) {
setParameter ( params , 'Destination.ToAddresses.member' , toAddresses ) ;
} else {
throw new NodeOperationError ( this . getNode ( ) , 'At least one "To Address" has to be added!' ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . configurationSetName ) {
params . push ( ` ConfigurationSetName= ${ additionalFields . configurationSetName } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . returnPath ) {
params . push ( ` ReturnPath= ${ additionalFields . returnPath } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . returnPathArn ) {
params . push ( ` ReturnPathArn= ${ additionalFields . returnPathArn } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . sourceArn ) {
params . push ( ` SourceArn= ${ additionalFields . sourceArn } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . replyToAddresses ) {
setParameter ( params , 'ReplyToAddresses.member' , additionalFields . replyToAddresses as string [ ] ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . bccAddresses ) {
setParameter ( params , 'Destination.BccAddresses.member' , additionalFields . bccAddresses as string [ ] ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . ccAddresses ) {
setParameter ( params , 'Destination.CcAddresses.member' , additionalFields . ccAddresses as string [ ] ) ;
}
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '/?Action=SendEmail&' + params . join ( '&' ) ) ;
2020-10-11 09:34:05 -07:00
}
2021-07-19 23:58:54 -07:00
if ( operation === 'sendTemplate' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const toAddresses = this . getNodeParameter ( 'toAddresses' , i ) as string [ ] ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const template = this . getNodeParameter ( 'templateName' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const fromEmail = this . getNodeParameter ( 'fromEmail' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) as IDataObject ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const templateDataUi = this . getNodeParameter ( 'templateDataUi' , i ) as IDataObject ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const params = [
` Template= ${ template } ` ,
` Source= ${ fromEmail } ` ,
] ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( toAddresses . length ) {
setParameter ( params , 'Destination.ToAddresses.member' , toAddresses ) ;
} else {
throw new NodeOperationError ( this . getNode ( ) , 'At least one "To Address" has to be added!' ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . configurationSetName ) {
params . push ( ` ConfigurationSetName= ${ additionalFields . configurationSetName } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . returnPath ) {
params . push ( ` ReturnPath= ${ additionalFields . returnPath } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . returnPathArn ) {
params . push ( ` ReturnPathArn= ${ additionalFields . returnPathArn } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . sourceArn ) {
params . push ( ` SourceArn= ${ additionalFields . sourceArn } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . replyToAddresses ) {
setParameter ( params , 'ReplyToAddresses.member' , additionalFields . replyToAddresses as string [ ] ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . bccAddresses ) {
setParameter ( params , 'Destination.BccAddresses.member' , additionalFields . bccAddresses as string [ ] ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . ccAddresses ) {
setParameter ( params , 'Destination.CcAddresses.member' , additionalFields . ccAddresses as string [ ] ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( templateDataUi ) {
const templateDataValues = ( templateDataUi as IDataObject ) . templateDataValues as IDataObject [ ] ;
const templateData : IDataObject = { } ;
if ( templateDataValues !== undefined ) {
for ( const templateDataValue of templateDataValues ) {
//@ts-ignore
templateData [ templateDataValue . key ] = templateDataValue . value ;
}
params . push ( ` TemplateData= ${ JSON . stringify ( templateData ) } ` ) ;
2020-10-13 06:05:09 -07:00
}
2020-10-11 09:34:05 -07:00
}
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '/?Action=SendTemplatedEmail&' + params . join ( '&' ) ) ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . SendTemplatedEmailResponse ;
}
2020-10-11 09:34:05 -07:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'template' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'create' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const subjectPart = this . getNodeParameter ( 'subjectPart' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const htmlPart = this . getNodeParameter ( 'htmlPart' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) as IDataObject ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const params = [
` Template.TemplateName= ${ templateName } ` ,
` Template.SubjectPart= ${ subjectPart } ` ,
` Template.HtmlPart=<h1> ${ htmlPart } </h1> ` ,
] ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( additionalFields . textPart ) {
params . push ( ` Template.TextPart= ${ additionalFields . textPart } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '/?Action=CreateTemplate&' + params . join ( '&' ) ) ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . CreateTemplateResponse ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'delete' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const params = [
` TemplateName= ${ templateName } ` ,
] ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '/?Action=DeleteTemplate&' + params . join ( '&' ) ) ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . DeleteTemplateResponse ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'get' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const params = [
` TemplateName= ${ templateName } ` ,
] ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '/?Action=GetTemplate&' + params . join ( '&' ) ) ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . GetTemplateResponse ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'getAll' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const returnAll = this . getNodeParameter ( 'returnAll' , i ) as boolean ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( returnAll === true ) {
responseData = await awsApiRequestSOAPAllItems . call ( this , 'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member' , 'email' , 'POST' , '/?Action=ListTemplates' ) ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
} else {
const limit = this . getNodeParameter ( 'limit' , i ) as number ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'GET' , ` /?Action=ListTemplates&MaxItems= ${ limit } ` ) ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . ListTemplatesResponse . ListTemplatesResult . TemplatesMetadata . member ;
}
2020-10-11 09:34:05 -07:00
}
2021-07-19 23:58:54 -07:00
if ( operation === 'update' ) {
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const updateFields = this . getNodeParameter ( 'updateFields' , i ) as IDataObject ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
const params = [
` Template.TemplateName= ${ templateName } ` ,
] ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( updateFields . textPart ) {
params . push ( ` Template.TextPart= ${ updateFields . textPart } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( updateFields . subjectPart ) {
params . push ( ` Template.SubjectPart= ${ updateFields . subjectPart } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( updateFields . subjectPart ) {
params . push ( ` Template.HtmlPart= ${ updateFields . htmlPart } ` ) ;
}
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = await awsApiRequestSOAP . call ( this , 'email' , 'POST' , '/?Action=UpdateTemplate&' + params . join ( '&' ) ) ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
responseData = responseData . UpdateTemplateResponse ;
}
2020-10-11 09:34:05 -07:00
}
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( Array . isArray ( responseData ) ) {
returnData . push . apply ( returnData , responseData as IDataObject [ ] ) ;
} else {
if ( responseData !== undefined ) {
returnData . push ( responseData as IDataObject ) ;
}
}
} catch ( error ) {
if ( this . continueOnFail ( ) ) {
returnData . push ( { error : error.message } ) ;
continue ;
2021-02-07 15:02:10 -08:00
}
2021-07-19 23:58:54 -07:00
throw error ;
2020-10-11 09:34:05 -07:00
}
}
return [ this . helpers . returnJsonArray ( returnData ) ] ;
}
}