Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n8n-3480 - feat(Pipedrive Node): Add support for filters to getAll:organization #3211

Merged
merged 3 commits into from
May 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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