Add mail-send operation to SendGrid node (#1526)

*  Add mail description

*  Add mail:send functionality

* 🔨 Refactor sandbox into additional options

* 🔨 Refactor MIME type as options

*  Implement send_at functionality

*  Add headers to additional options

*  Implement attachments

* 🔥 Remove logging

*  Improvements

*  Fix default operation

* 🔨 Fix HTML option

* 🔨 Fix subject in dynamic template email

Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Iván Ovejero
2021-03-26 08:48:52 +01:00
committed by GitHub
parent 46138f7f1e
commit b60b66d006
3 changed files with 550 additions and 18 deletions

View File

@@ -13,7 +13,7 @@ import {
IDataObject,
} from 'n8n-workflow';
export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, qs: IDataObject = {}, uri?: string | undefined): Promise<any> { // tslint:disable-line:no-any
export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('sendGridApi') as IDataObject;
const host = 'api.sendgrid.com/v3';
@@ -25,7 +25,7 @@ export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunction
method,
qs,
body,
uri: uri || `https://${host}${endpoint}`,
uri: `https://${host}${endpoint}`,
json: true,
};
@@ -33,6 +33,10 @@ export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunction
delete options.body;
}
if (Object.keys(option).length !== 0) {
Object.assign(options, option);
}
try {
//@ts-ignore
return await this.helpers.request!(options);