Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import type {
|
|
ICredentialDataDecryptedObject,
|
|
ICredentialTestRequest,
|
|
ICredentialType,
|
|
IHttpRequestOptions,
|
|
INodeProperties,
|
|
} from 'n8n-workflow';
|
|
|
|
export class MailerLiteApi implements ICredentialType {
|
|
name = 'mailerLiteApi';
|
|
|
|
displayName = 'Mailer Lite API';
|
|
|
|
documentationUrl = 'mailerlite';
|
|
|
|
properties: INodeProperties[] = [
|
|
{
|
|
displayName: 'API Key',
|
|
name: 'apiKey',
|
|
type: 'string',
|
|
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',
|
|
},
|
|
};
|
|
}
|