n8n/packages/nodes-base/credentials/NextCloudApi.credentials.ts

52 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-06-23 03:35:23 -07:00
import {
ICredentialDataDecryptedObject,
ICredentialTestRequest,
2019-06-23 03:35:23 -07:00
ICredentialType,
IHttpRequestOptions,
INodeProperties,
2019-06-23 03:35:23 -07:00
} from 'n8n-workflow';
export class NextCloudApi implements ICredentialType {
name = 'nextCloudApi';
displayName = 'NextCloud API';
documentationUrl = 'nextCloud';
properties: INodeProperties[] = [
2019-06-23 03:35:23 -07:00
{
displayName: 'Web DAV URL',
name: 'webDavUrl',
type: 'string',
2020-07-22 14:52:40 -07:00
placeholder: 'https://nextcloud.example.com/remote.php/webdav',
2019-06-23 03:35:23 -07:00
default: '',
},
{
displayName: 'User',
name: 'user',
type: 'string',
2019-06-23 03:35:23 -07:00
default: '',
},
{
displayName: 'Password',
name: 'password',
type: 'string',
2019-06-23 03:35:23 -07:00
default: '',
},
];
async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
requestOptions.auth = {
username: credentials.user as string,
password: credentials.password as string,
};
return requestOptions;
}
test: ICredentialTestRequest = {
request: {
baseURL: "={{$credentials.webDavUrl.replace('/remote.php/webdav', '')}}",
url: '/ocs/v1.php/cloud/capabilities',
headers: { 'OCS-APIRequest': true },
},
};
2019-06-23 03:35:23 -07:00
}