2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2022-07-05 00:02:25 -07:00
|
|
|
IAuthenticateGeneric,
|
|
|
|
ICredentialTestRequest,
|
|
|
|
ICredentialType,
|
|
|
|
INodeProperties,
|
|
|
|
} from 'n8n-workflow';
|
2021-03-18 15:34:15 -07:00
|
|
|
|
|
|
|
export class DeepLApi implements ICredentialType {
|
|
|
|
name = 'deepLApi';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-03-18 15:34:15 -07:00
|
|
|
displayName = 'DeepL API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-03-18 15:34:15 -07:00
|
|
|
documentationUrl = 'deepL';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
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',
|
2022-11-01 09:41:45 -07:00
|
|
|
typeOptions: { password: true },
|
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: {
|
2022-07-24 08:36:17 -07:00
|
|
|
baseURL:
|
|
|
|
'={{$credentials.apiPlan === "pro" ? "https://api.deepl.com/v2" : "https://api-free.deepl.com/v2" }}',
|
2022-07-05 00:02:25 -07:00
|
|
|
url: '/usage',
|
|
|
|
},
|
|
|
|
};
|
2021-03-18 15:34:15 -07:00
|
|
|
}
|