mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(MailerLite Node): Update node to support new api (#11933)
This commit is contained in:
@@ -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',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user