2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2022-07-04 00:39:56 -07:00
|
|
|
IAuthenticateGeneric,
|
|
|
|
ICredentialTestRequest,
|
2019-12-30 13:08:22 -08:00
|
|
|
ICredentialType,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2019-12-30 13:08:22 -08:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class WordpressApi implements ICredentialType {
|
|
|
|
name = 'wordpressApi';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2019-12-30 13:08:22 -08:00
|
|
|
displayName = 'Wordpress API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2020-08-17 05:42:09 -07:00
|
|
|
documentationUrl = 'wordpress';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2019-12-30 13:08:22 -08:00
|
|
|
{
|
|
|
|
displayName: 'Username',
|
|
|
|
name: 'username',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2019-12-30 13:08:22 -08:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Password',
|
|
|
|
name: 'password',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2022-03-13 03:42:23 -07:00
|
|
|
typeOptions: {
|
|
|
|
password: true,
|
|
|
|
},
|
2019-12-30 13:08:22 -08:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
2020-01-03 19:47:19 -08:00
|
|
|
displayName: 'Wordpress URL',
|
|
|
|
name: 'url',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2019-12-30 13:08:22 -08:00
|
|
|
default: '',
|
2020-01-03 19:47:19 -08:00
|
|
|
placeholder: 'https://example.com',
|
2019-12-30 13:08:22 -08:00
|
|
|
},
|
2024-01-03 02:52:01 -08:00
|
|
|
{
|
|
|
|
displayName: 'Ignore SSL Issues',
|
|
|
|
name: 'allowUnauthorizedCerts',
|
|
|
|
type: 'boolean',
|
|
|
|
description: 'Whether to connect even if SSL certificate validation is not possible',
|
|
|
|
default: false,
|
|
|
|
},
|
2019-12-30 13:08:22 -08:00
|
|
|
];
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-07-24 08:36:17 -07:00
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
|
|
|
properties: {
|
|
|
|
auth: {
|
|
|
|
username: '={{$credentials.username}}',
|
|
|
|
password: '={{$credentials.password}}',
|
|
|
|
},
|
2022-07-04 00:39:56 -07:00
|
|
|
},
|
2022-07-24 08:36:17 -07:00
|
|
|
};
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-07-04 00:39:56 -07:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: '={{$credentials?.url}}/wp-json/wp/v2',
|
|
|
|
url: '/users',
|
|
|
|
method: 'GET',
|
2024-01-03 02:52:01 -08:00
|
|
|
skipSslCertificateValidation: '={{$credentials.allowUnauthorizedCerts}}',
|
2022-07-04 00:39:56 -07:00
|
|
|
},
|
|
|
|
};
|
2019-12-30 13:08:22 -08:00
|
|
|
}
|