2022-07-05 00:02:25 -07:00
|
|
|
import {
|
|
|
|
IAuthenticateGeneric,
|
|
|
|
ICredentialTestRequest,
|
|
|
|
ICredentialType,
|
|
|
|
INodeProperties,
|
|
|
|
} from 'n8n-workflow';
|
2021-03-18 15:34:15 -07:00
|
|
|
|
|
|
|
export class DeepLApi implements ICredentialType {
|
|
|
|
name = 'deepLApi';
|
|
|
|
displayName = 'DeepL API';
|
|
|
|
documentationUrl = 'deepL';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2021-03-18 15:34:15 -07:00
|
|
|
{
|
|
|
|
displayName: 'API Key',
|
|
|
|
name: 'apiKey',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2021-03-18 15:34:15 -07:00
|
|
|
default: '',
|
|
|
|
},
|
2021-05-30 10:33:43 -07:00
|
|
|
{
|
|
|
|
displayName: 'API Plan',
|
|
|
|
name: 'apiPlan',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'options',
|
2021-05-30 10:33:43 -07:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Pro Plan',
|
|
|
|
value: 'pro',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Free Plan',
|
|
|
|
value: 'free',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'pro',
|
|
|
|
},
|
2021-03-18 15:34:15 -07:00
|
|
|
];
|
2022-07-05 00:02:25 -07:00
|
|
|
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
|
|
|
properties: {
|
|
|
|
qs: {
|
|
|
|
auth_key: '={{$credentials.apiKey}}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: '={{$credentials.apiPlan === "pro" ? "https://api.deepl.com/v2" : "https://api-free.deepl.com/v2" }}',
|
|
|
|
url: '/usage',
|
|
|
|
},
|
|
|
|
};
|
2021-03-18 15:34:15 -07:00
|
|
|
}
|