forked from n8n-io/n8n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLemlistApi.credentials.ts
42 lines (36 loc) · 964 Bytes
/
LemlistApi.credentials.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type {
ICredentialDataDecryptedObject,
ICredentialTestRequest,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';
export class LemlistApi implements ICredentialType {
name = 'lemlistApi';
displayName = 'Lemlist API';
documentationUrl = 'lemlist';
properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
typeOptions: { password: true },
default: '',
},
];
async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
const encodedApiKey = Buffer.from(':' + (credentials.apiKey as string)).toString('base64');
requestOptions.headers!.Authorization = `Basic ${encodedApiKey}`;
requestOptions.headers!['user-agent'] = 'n8n';
return requestOptions;
}
test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.lemlist.com/api',
url: '/campaigns',
},
};
}