Add organization operations

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-12-02 15:01:09 +01:00
parent 6ba68ee830
commit ba4c229ef1
8 changed files with 447 additions and 0 deletions

View File

@@ -0,0 +1,130 @@
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { proboApiRequest } from '../../GenericFunctions';
export const description: INodeProperties[] = [
{
displayName: 'Organization ID',
name: 'organizationId',
type: 'string',
displayOptions: {
show: {
resource: ['organization'],
operation: ['update'],
},
},
default: '',
description: 'The ID of the organization to update',
required: true,
},
{
displayName: 'Name',
name: 'name',
type: 'string',
displayOptions: {
show: {
resource: ['organization'],
operation: ['update'],
},
},
default: '',
description: 'The name of the organization',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
displayOptions: {
show: {
resource: ['organization'],
operation: ['update'],
},
},
default: '',
description: 'The description of the organization',
},
{
displayName: 'Website URL',
name: 'websiteUrl',
type: 'string',
displayOptions: {
show: {
resource: ['organization'],
operation: ['update'],
},
},
default: '',
description: 'The website URL of the organization',
},
{
displayName: 'Email',
name: 'email',
type: 'string',
displayOptions: {
show: {
resource: ['organization'],
operation: ['update'],
},
},
default: '',
description: 'The email address of the organization',
},
{
displayName: 'Headquarter Address',
name: 'headquarterAddress',
type: 'string',
displayOptions: {
show: {
resource: ['organization'],
operation: ['update'],
},
},
default: '',
description: 'The headquarter address of the organization',
},
];
export async function execute(
this: IExecuteFunctions,
itemIndex: number,
): Promise<INodeExecutionData> {
const organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
const name = this.getNodeParameter('name', itemIndex, '') as string;
const description = this.getNodeParameter('description', itemIndex, '') as string;
const websiteUrl = this.getNodeParameter('websiteUrl', itemIndex, '') as string;
const email = this.getNodeParameter('email', itemIndex, '') as string;
const headquarterAddress = this.getNodeParameter('headquarterAddress', itemIndex, '') as string;
const query = `
mutation UpdateOrganization($input: UpdateOrganizationInput!) {
updateOrganization(input: $input) {
organization {
id
name
description
websiteUrl
email
headquarterAddress
logoUrl
horizontalLogoUrl
createdAt
updatedAt
}
}
}
`;
const input: Record<string, string> = { organizationId };
if (name) input.name = name;
if (description) input.description = description;
if (websiteUrl) input.websiteUrl = websiteUrl;
if (email) input.email = email;
if (headquarterAddress) input.headquarterAddress = headquarterAddress;
const responseData = await proboApiRequest.call(this, query, { input });
return {
json: responseData,
pairedItem: { item: itemIndex },
};
}