From 1ef10dd23fef0b2e3e0ef76c8116d3bebc36bc4e Mon Sep 17 00:00:00 2001 From: Tom <19203795+that-one-tom@users.noreply.github.com> Date: Fri, 6 May 2022 17:42:26 +0200 Subject: [PATCH] feat(Pipedrive Node): Add support for filters to getAll:organization (#3211) * feat(Pipedrive Node): Add support for filters to getAll:organization * Fixed lint issue * :zap: Small improvement Co-authored-by: Jonathan Bennetts Co-authored-by: ricardo --- .../nodes/Pipedrive/Pipedrive.node.ts | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index 432c13b0a7..dd926a9ad5 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -3628,6 +3628,46 @@ export class Pipedrive implements INodeType { ], }, + // ---------------------------------- + // organization:getAll + // ---------------------------------- + { + displayName: 'Filters', + name: 'filters', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'organization', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'First Char', + name: 'firstChar', + type: 'string', + default: '', + description: 'If supplied, only organizations whose name starts with the specified letter will be returned', + }, + { + displayName: 'Predefined Filter', + name: 'filterId', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getFilters', + }, + default: '', + description: 'ID of the filter to use.', + }, + ], + }, + // ---------------------------------- // person:getAll // ---------------------------------- @@ -3980,6 +4020,7 @@ export class Pipedrive implements INodeType { 'deal': 'deals', 'activity': 'activity', 'person': 'people', + 'organization': 'org', } as { [id: string]: string }; const { data } = await pipedriveApiRequest.call(this, 'GET', '/filters', {}, { type: type[resource] as string }); @@ -4865,6 +4906,17 @@ export class Pipedrive implements INodeType { qs.limit = this.getNodeParameter('limit', i) as number; } + const filters = this.getNodeParameter('filters', i) as IDataObject; + + if (filters.filterId) { + qs.filter_id = filters.filterId as string; + } + + if (filters.firstChar) { + qs.first_char = filters.firstChar as string; + qs.first_char = qs.first_char.substring(0, 1); + } + endpoint = `/organizations`; } else if (operation === 'update') {