Skip to content

Commit

Permalink
feat(Pipedrive Node): Add support for filters to getAll:organization (#…
Browse files Browse the repository at this point in the history
…3211)

* feat(Pipedrive Node): Add support for filters to getAll:organization

* Fixed lint issue

* ⚡ Small improvement

Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
  • Loading branch information
3 people authored May 6, 2022
1 parent 71afcd6 commit 1ef10dd
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ----------------------------------
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit 1ef10dd

Please sign in to comment.