2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2022-05-15 10:48:17 -07:00
|
|
|
ICredentialDataDecryptedObject,
|
|
|
|
ICredentialTestRequest,
|
2019-07-12 08:54:15 -07:00
|
|
|
ICredentialType,
|
2022-05-15 10:48:17 -07:00
|
|
|
IHttpRequestOptions,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2019-07-12 08:54:15 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class TrelloApi implements ICredentialType {
|
|
|
|
name = 'trelloApi';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2019-07-12 08:54:15 -07:00
|
|
|
displayName = 'Trello API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2020-08-17 05:42:09 -07:00
|
|
|
documentationUrl = 'trello';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2019-07-12 08:54: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 },
|
2022-05-15 10:48:17 -07:00
|
|
|
required: true,
|
2019-07-12 08:54:15 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'API Token',
|
|
|
|
name: 'apiToken',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2023-08-01 04:08:25 -07:00
|
|
|
typeOptions: { password: true },
|
2022-05-15 10:48:17 -07:00
|
|
|
required: true,
|
2019-07-12 08:54:15 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'OAuth Secret',
|
|
|
|
name: 'oauthSecret',
|
2022-05-15 10:48:17 -07:00
|
|
|
type: 'hidden',
|
2023-08-01 04:08:25 -07:00
|
|
|
typeOptions: { password: true },
|
2019-07-12 08:54:15 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
];
|
2022-05-15 10:48:17 -07:00
|
|
|
|
2022-07-24 08:36:17 -07:00
|
|
|
async authenticate(
|
|
|
|
credentials: ICredentialDataDecryptedObject,
|
|
|
|
requestOptions: IHttpRequestOptions,
|
|
|
|
): Promise<IHttpRequestOptions> {
|
2022-05-15 10:48:17 -07:00
|
|
|
requestOptions.qs = {
|
|
|
|
...requestOptions.qs,
|
2022-07-24 08:36:17 -07:00
|
|
|
key: credentials.apiKey,
|
|
|
|
token: credentials.apiToken,
|
2022-05-15 10:48:17 -07:00
|
|
|
};
|
|
|
|
return requestOptions;
|
|
|
|
}
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-05-15 10:48:17 -07:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: 'https://api.trello.com',
|
|
|
|
url: '=/1/tokens/{{$credentials.apiToken}}/member',
|
|
|
|
},
|
|
|
|
};
|
2019-07-12 08:54:15 -07:00
|
|
|
}
|