feat(MailerLite Node): Update node to support new api (#11933)

This commit is contained in:
Jon
2024-12-16 13:44:52 +00:00
committed by GitHub
parent 271401d882
commit d6b8e65abe
19 changed files with 2830 additions and 394 deletions

View File

@@ -1,4 +1,10 @@
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
import type {
ICredentialDataDecryptedObject,
ICredentialTestRequest,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';
export class MailerLiteApi implements ICredentialType {
name = 'mailerLiteApi';
@@ -15,5 +21,37 @@ export class MailerLiteApi implements ICredentialType {
typeOptions: { password: true },
default: '',
},
{
displayName: 'Classic API',
name: 'classicApi',
type: 'boolean',
default: true,
description:
'If the Classic API should be used, If this is your first time using this node this should be false.',
},
];
async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
if (credentials.classicApi === true) {
requestOptions.headers = {
'X-MailerLite-ApiKey': credentials.apiKey as string,
};
} else {
requestOptions.headers = {
Authorization: `Bearer ${credentials.apiKey as string}`,
};
}
return requestOptions;
}
test: ICredentialTestRequest = {
request: {
baseURL:
'={{$credentials.classicApi ? "https://api.mailerlite.com/api/v2" : "https://connect.mailerlite.com/api"}}',
url: '/groups',
},
};
}