2020-12-07 23:40:29 -08:00
|
|
|
import {
|
2022-05-14 01:39:28 -07:00
|
|
|
ICredentialDataDecryptedObject,
|
|
|
|
ICredentialTestRequest,
|
2020-12-07 23:40:29 -08:00
|
|
|
ICredentialType,
|
2022-05-14 01:39:28 -07:00
|
|
|
IHttpRequestOptions,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2020-12-07 23:40:29 -08:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class GhostContentApi implements ICredentialType {
|
|
|
|
name = 'ghostContentApi';
|
|
|
|
displayName = 'Ghost Content API';
|
|
|
|
documentationUrl = 'ghost';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2020-12-07 23:40:29 -08:00
|
|
|
{
|
|
|
|
displayName: 'URL',
|
|
|
|
name: 'url',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-12-07 23:40:29 -08:00
|
|
|
default: '',
|
|
|
|
placeholder: 'http://localhost:3001',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'API Key',
|
|
|
|
name: 'apiKey',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-12-07 23:40:29 -08:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
];
|
2022-05-14 01:39:28 -07:00
|
|
|
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
|
|
|
requestOptions.qs = {
|
|
|
|
...requestOptions.qs,
|
|
|
|
'key': credentials.apiKey,
|
|
|
|
};
|
|
|
|
return requestOptions;
|
|
|
|
}
|
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: '={{$credentials.url}}',
|
|
|
|
url: '/ghost/api/v3/content/settings/',
|
|
|
|
method: 'GET',
|
|
|
|
},
|
|
|
|
};
|
2020-12-07 23:40:29 -08:00
|
|
|
}
|