n8n/packages/nodes-base/credentials/ZendeskApi.credentials.ts
Iván Ovejero 57afd480ab
refactor: Format all credentials (#3720)
* Apply Prettier to all credentials

* Fix quotes for lint

* 👕 Remove `quotemark` rule

* 👕 Run Prettier to take over quotes

* ⬆️ Upgrade `eslint-plugin-n8n-nodes-base`

* 📦 Update `package-lock.json`

Co-authored-by: Omar Ajoue <krynble@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2022-07-24 17:36:17 +02:00

53 lines
1.1 KiB
TypeScript

import {
ICredentialDataDecryptedObject,
ICredentialTestRequest,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';
export class ZendeskApi implements ICredentialType {
name = 'zendeskApi';
displayName = 'Zendesk API';
documentationUrl = 'zendesk';
properties: INodeProperties[] = [
{
displayName: 'Subdomain',
name: 'subdomain',
type: 'string',
description: 'The subdomain of your Zendesk work environment',
placeholder: 'company',
default: '',
},
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
default: '',
},
{
displayName: 'API Token',
name: 'apiToken',
type: 'string',
default: '',
},
];
async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
requestOptions.auth = {
username: `${credentials.email}/token`,
password: credentials.apiToken as string,
};
return requestOptions;
}
test: ICredentialTestRequest = {
request: {
baseURL: '=https://{{$credentials.subdomain}}.zendesk.com/api/v2',
url: '/ticket_fields.json',
},
};
}