Hi everyone! So I do want to create a node which incorporates the Personio functionalities(in the declarative way). For testing I created just a simple GET resource which uses an OAuth2 conn as auth method. First thing would be, is it possible to use the OAuth conn with the declarative type? Do you see any issues in my code that might not allow this node to function correctly? Thanks in advance!
PersonioOAuth2Api.credentials.ts:
import {
IAuthenticateGeneric,
ICredentialType,
INodeProperties,
} from ‘n8n-workflow’;
export class PersonioOAuth2Api implements ICredentialType {
name = ‘personioOAuth2Api’;
displayName = ‘Personio OAuth2 API’;
extends = [‘oAuth2Api’];
documentationUrl = 'https://developer.personio.de/reference/introduction';
properties: INodeProperties[] = [
//{
// displayName: 'Grant Type',
// name: 'grantType',
// type: 'hidden',
// default: 'clientCredentials',
//},
{
displayName: 'Access Token URL',
name: 'accessTokenUrl',
type: 'hidden',
default: 'https://api.personio.de/v1/auth',
required: true,
},
{
displayName: 'Scope',
name: 'scope',
type: 'hidden',
default: '',
required: true,
},
{
displayName: 'Auth URI Query Parameters',
name: 'authQueryParameters',
type: 'hidden',
default: '',
},
{
displayName: 'Authentication',
name: 'authentication',
type: 'hidden',
default: 'body',
},
];
}
Personio.node.ts:
import { INodeType, INodeTypeDescription } from ‘n8n-workflow’;
//import { httpVerbFields, httpVerbOperations } from ‘./HttpVerbDescription’;
export class Personio implements INodeType {
description: INodeTypeDescription = {
displayName: ‘Personio’,
name: ‘Personio’,
icon: ‘file:personio.svg’,
group: [‘transform’],
version: 1,
subtitle: ‘={{$parameter[“operation”] + ": " + $parameter[“resource”]}}’,
description: ‘Personio API Operations’,
defaults: {
name: ‘Personio API Operations’,
},
inputs: [‘main’],
outputs: [‘main’],
credentials: [
{
name: ‘personioOAuth2Api’,
required: false,
},
],
requestDefaults: {
baseURL: ‘https://api.personio.de/v1’,
url: ‘’,
headers: {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
},
},
/**
* In the properties array we have two mandatory options objects required
*
* [Resource & Operation]
*
* Build a node - n8n Documentation
*
* In our example, the operations are separated into their own file (HTTPVerbDescription.ts)
* to keep this class easy to read.
*
*/
properties: [
{
displayName: ‘Resource’,
name: ‘resource’,
type: ‘options’,
noDataExpression: true,
options: [
{
name: ‘Employee’,
value: ‘Employee’,
},
],
default: ‘Employee’,
},
// Operations for Employee will go here
{
displayName: ‘Operation’,
name: ‘operation’,
type: ‘options’,
noDataExpression: true,
displayOptions: {
show: {
resource: [‘Employee’],
},
},
options: [
{
name: ‘Get an Employee’,
value: ‘getAEmployee’,
action: ‘Test’,
description: ‘Test’,
routing: {
request: {
method: ‘GET’,
url: ‘=/company/employees/{{$parameters.employeeId}}’,
},
},
},
],
default: ‘getAEmployee’,
},
// Fields for Employee operation
// Fields for getAEmployee operation
{
displayName: 'Employee ID',
description: 'Type in the Employee ID',
required: true,
name: 'employeeId',
type: 'string',
default: '',
hint: 'Test.',
displayOptions: {
show: {
resource: ['Employee'],
operation: ['getAEmployee'],
},
},
}
],
};
}