2022-08-01 13:47:55 -07:00
import { IExecuteFunctions } from 'n8n-core' ;
2020-10-11 09:34:05 -07:00
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' ;
2022-08-01 13:47:55 -07:00
import { awsApiRequestSOAP , awsApiRequestSOAPAllItems } from './GenericFunctions' ;
2020-10-11 09:34:05 -07:00
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a new custom verification email template' ,
2022-07-10 13:50:51 -07:00
action : 'Create a custom verification email' ,
2021-02-07 15:02:10 -08:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete an existing custom verification email template' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a custom verification email' ,
2021-02-07 15:02:10 -08:00
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get the custom email verification template' ,
2022-07-10 13:50:51 -07:00
action : 'Get a custom verification email' ,
2021-02-07 15:02:10 -08:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2021-02-07 15:02:10 -08:00
value : 'getAll' ,
2022-08-01 13:47:55 -07:00
description :
2022-09-13 03:36:36 -07:00
'Get many of the existing custom verification email templates for your account' ,
2022-09-08 08:10:13 -07:00
action : 'Get many custom verifications' ,
2021-02-07 15:02:10 -08:00
} ,
{
name : 'Send' ,
value : 'send' ,
description : 'Add an email address to the list of identities' ,
2022-07-10 13:50:51 -07:00
action : 'Send a custom verification email' ,
2021-02-07 15:02:10 -08:00
} ,
{
name : 'Update' ,
value : 'update' ,
2022-05-06 14:01:25 -07:00
description : 'Update an existing custom verification email template' ,
2022-07-10 13:50:51 -07:00
action : 'Update a custom verification email' ,
2021-02-07 15:02:10 -08:00
} ,
] ,
default : 'create' ,
} ,
{
displayName : 'From Email' ,
name : 'fromEmailAddress' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'create' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'create' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'create' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
2022-08-01 13:47:55 -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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'create' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'create' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
required : true ,
2022-08-01 13:47:55 -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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'create' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
required : true ,
2022-08-01 13:47:55 -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' ,
2022-06-20 07:54:01 -07:00
placeholder : 'name@email.com' ,
2021-02-07 15:02:10 -08:00
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'send' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'send' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
default : '' ,
required : true ,
2022-08-01 13:47:55 -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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'send' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'update' , 'delete' , 'get' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'update' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
options : [
{
displayName : 'Failure Redirection URL' ,
name : 'failureRedirectionURL' ,
type : 'string' ,
2022-08-01 13:47:55 -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-08-01 13:47:55 -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-08-01 13:47:55 -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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'getAll' ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'customVerificationEmail' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2021-02-07 15:02:10 -08:00
} ,
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
options : [
{
name : 'Send' ,
value : 'send' ,
2022-07-10 13:50:51 -07:00
action : 'Send an email' ,
2020-10-11 09:34:05 -07:00
} ,
{
name : 'Send Template' ,
value : 'sendTemplate' ,
2022-07-10 13:50:51 -07:00
action : 'Send an email based on a template' ,
2020-10-11 09:34:05 -07:00
} ,
] ,
default : 'send' ,
} ,
{
displayName : 'Is Body HTML' ,
name : 'isBodyHtml' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'send' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether body is HTML or simple text' ,
2020-10-11 09:34:05 -07:00
} ,
{
displayName : 'Subject' ,
name : 'subject' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'send' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
default : '' ,
required : true ,
} ,
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'send' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'send' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'send' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'sendTemplate' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
default : '' ,
2022-08-01 13:47:55 -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/code-examples/expressions/">expression</a>.' ,
2020-10-11 09:34:05 -07:00
} ,
{
displayName : 'From Email' ,
name : 'fromEmail' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'sendTemplate' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'sendTemplate' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
placeholder : 'info@example.com' ,
default : [ ] ,
} ,
{
displayName : 'Template Data' ,
name : 'templateDataUi' ,
type : 'fixedCollection' ,
placeholder : 'Add Data' ,
typeOptions : {
multipleValues : true ,
} ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'sendTemplate' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'email' ] ,
operation : [ 'send' , 'sendTemplate' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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' ,
2022-08-01 13:47:55 -07:00
description :
'Email address that bounces and complaints will be forwarded to when feedback forwarding is enabled' ,
2020-10-11 09:34:05 -07:00
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'template' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a template' ,
2022-07-10 13:50:51 -07:00
action : 'Create a template' ,
2020-10-11 09:34:05 -07:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a template' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a template' ,
2020-10-11 09:34:05 -07:00
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a template' ,
2022-07-10 13:50:51 -07:00
action : 'Get a template' ,
2020-10-11 09:34:05 -07:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2020-10-11 09:34:05 -07:00
value : 'getAll' ,
2022-09-13 03:36:36 -07:00
description : 'Get many templates' ,
2022-09-08 08:10:13 -07:00
action : 'Get many templates' ,
2020-10-11 09:34:05 -07:00
} ,
{
name : 'Update' ,
value : 'update' ,
description : 'Update a template' ,
2022-07-10 13:50:51 -07:00
action : 'Update a template' ,
2020-10-11 09:34:05 -07:00
} ,
] ,
default : 'create' ,
} ,
{
displayName : 'Template Name' ,
name : 'templateName' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'template' ] ,
operation : [ 'update' , 'create' , 'get' , 'delete' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'template' ] ,
operation : [ 'create' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'template' ] ,
operation : [ 'create' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'template' ] ,
operation : [ 'create' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
options : [
{
displayName : 'Text Part' ,
name : 'textPart' ,
type : 'string' ,
2022-08-01 13:47:55 -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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'template' ] ,
operation : [ 'update' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
options : [
{
displayName : 'Text Part' ,
name : 'textPart' ,
type : 'string' ,
2022-08-01 13:47:55 -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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'template' ] ,
operation : [ 'getAll' ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
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 : {
2022-08-01 13:47:55 -07:00
resource : [ 'template' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2020-10-11 09:34:05 -07:00
} ,
} ,
} ,
] ,
} ;
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 [ ] = [ ] ;
2022-08-01 13:47:55 -07:00
const templates = await awsApiRequestSOAPAllItems . call (
this ,
'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member' ,
'email' ,
'POST' ,
'/?Action=ListTemplates' ,
) ;
2020-10-11 09:34:05 -07:00
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' ) {
if ( operation === 'create' ) {
2022-08-01 13:47:55 -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
2022-08-01 13:47:55 -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
2022-08-01 13:47:55 -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' ) {
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
2022-08-01 13:47:55 -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' ) {
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2021-02-07 15:02:10 -08:00
2022-08-01 13:47:55 -07:00
const params = [ ` TemplateName= ${ templateName } ` ] ;
2021-02-07 15:02:10 -08:00
2022-08-01 13:47:55 -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' ) {
2022-11-18 05:31:38 -08:00
const returnAll = this . getNodeParameter ( 'returnAll' , i ) ;
2021-02-07 15:02:10 -08:00
2021-07-19 23:58:54 -07:00
if ( returnAll === true ) {
2022-08-01 13:47:55 -07:00
responseData = await awsApiRequestSOAPAllItems . call (
this ,
'ListCustomVerificationEmailTemplatesResponse.ListCustomVerificationEmailTemplatesResult.CustomVerificationEmailTemplates.member' ,
'email' ,
'POST' ,
'/?Action=ListCustomVerificationEmailTemplates' ,
) ;
2021-07-19 23:58:54 -07:00
} else {
2022-11-18 06:26:22 -08:00
const limit = this . getNodeParameter ( 'limit' , i ) ;
2021-02-07 15:02:10 -08:00
2022-08-01 13:47:55 -07:00
responseData = await awsApiRequestSOAP . call (
this ,
'email' ,
'GET' ,
` /?Action=ListCustomVerificationEmailTemplates&MaxResults= ${ limit } ` ,
) ;
responseData =
responseData . ListCustomVerificationEmailTemplatesResponse
. ListCustomVerificationEmailTemplatesResult . CustomVerificationEmailTemplates
. member ;
2021-07-19 23:58:54 -07:00
}
2021-02-07 15:02:10 -08:00
}
2021-07-19 23:58:54 -07:00
if ( operation === 'send' ) {
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
2022-11-18 07:29:44 -08:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) ;
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
2022-08-01 13:47:55 -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' ) {
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2021-02-07 15:02:10 -08:00
2022-11-18 07:29:44 -08:00
const updateFields = this . getNodeParameter ( 'updateFields' , i ) ;
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
2022-08-01 13:47:55 -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' ) {
if ( operation === 'send' ) {
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
2022-11-18 07:29:44 -08:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) ;
2020-10-11 09:34:05 -07:00
2022-08-23 00:48:44 -07:00
const params = [
` Message.Subject.Data= ${ encodeURIComponent ( 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 {
2022-08-01 13:47:55 -07:00
throw new NodeOperationError (
this . getNode ( ) ,
'At least one "To Address" has to be added!' ,
{ itemIndex : i } ,
) ;
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 ( 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 ) {
2022-08-01 13:47:55 -07:00
setParameter (
params ,
'ReplyToAddresses.member' ,
additionalFields . replyToAddresses as string [ ] ,
) ;
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 ( additionalFields . bccAddresses ) {
2022-08-01 13:47:55 -07:00
setParameter (
params ,
'Destination.BccAddresses.member' ,
additionalFields . bccAddresses as string [ ] ,
) ;
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 ( additionalFields . ccAddresses ) {
2022-08-01 13:47:55 -07:00
setParameter (
params ,
'Destination.CcAddresses.member' ,
additionalFields . ccAddresses as string [ ] ,
) ;
2021-07-19 23:58:54 -07:00
}
2022-08-01 13:47:55 -07:00
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' ) {
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
2022-11-18 07:29:44 -08:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) ;
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
2022-08-01 13:47:55 -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 {
2022-08-01 13:47:55 -07:00
throw new NodeOperationError (
this . getNode ( ) ,
'At least one "To Address" has to be added!' ,
{ itemIndex : i } ,
) ;
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 ( 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 ) {
2022-08-01 13:47:55 -07:00
setParameter (
params ,
'ReplyToAddresses.member' ,
additionalFields . replyToAddresses as string [ ] ,
) ;
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 ( additionalFields . bccAddresses ) {
2022-08-01 13:47:55 -07:00
setParameter (
params ,
'Destination.BccAddresses.member' ,
additionalFields . bccAddresses as string [ ] ,
) ;
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 ( additionalFields . ccAddresses ) {
2022-08-01 13:47:55 -07:00
setParameter (
params ,
'Destination.CcAddresses.member' ,
additionalFields . ccAddresses as string [ ] ,
) ;
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 ( templateDataUi ) {
2022-08-01 13:47:55 -07:00
const templateDataValues = ( templateDataUi as IDataObject )
. templateDataValues as IDataObject [ ] ;
2021-07-19 23:58:54 -07:00
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
}
2022-08-01 13:47:55 -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' ) {
if ( operation === 'create' ) {
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
2022-11-18 07:29:44 -08:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) ;
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
2022-08-01 13:47:55 -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' ) {
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2020-10-11 09:34:05 -07:00
2022-08-01 13:47:55 -07:00
const params = [ ` TemplateName= ${ templateName } ` ] ;
2020-10-11 09:34:05 -07:00
2022-08-01 13:47:55 -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' ) {
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2020-10-11 09:34:05 -07:00
2022-08-01 13:47:55 -07:00
const params = [ ` TemplateName= ${ templateName } ` ] ;
2020-10-11 09:34:05 -07:00
2022-08-01 13:47:55 -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' ) {
2022-11-18 05:31:38 -08:00
const returnAll = this . getNodeParameter ( 'returnAll' , i ) ;
2020-10-11 09:34:05 -07:00
2021-07-19 23:58:54 -07:00
if ( returnAll === true ) {
2022-08-01 13:47:55 -07:00
responseData = await awsApiRequestSOAPAllItems . call (
this ,
'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member' ,
'email' ,
'POST' ,
'/?Action=ListTemplates' ,
) ;
2021-07-19 23:58:54 -07:00
} else {
2022-11-18 06:26:22 -08:00
const limit = this . getNodeParameter ( 'limit' , i ) ;
2020-10-11 09:34:05 -07:00
2022-08-01 13:47:55 -07:00
responseData = await awsApiRequestSOAP . call (
this ,
'email' ,
'GET' ,
` /?Action=ListTemplates&MaxItems= ${ limit } ` ,
) ;
2020-10-11 09:34:05 -07:00
2022-08-01 13:47:55 -07:00
responseData =
responseData . ListTemplatesResponse . ListTemplatesResult . TemplatesMetadata . member ;
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 ( operation === 'update' ) {
const templateName = this . getNodeParameter ( 'templateName' , i ) as string ;
2020-10-11 09:34:05 -07:00
2022-11-18 07:29:44 -08:00
const updateFields = this . getNodeParameter ( 'updateFields' , i ) ;
2020-10-11 09:34:05 -07:00
2022-08-01 13:47:55 -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
2022-08-01 13:47:55 -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 ) ] ;
}
}