From 1cc00d910158898f2a3786cdc0f2c3d55c2ef3af Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Wed, 10 Jul 2019 08:40:59 +0200 Subject: [PATCH] :sparkles: Add more functionality to Pipedrive-Node --- .../nodes/Pipedrive/Pipedrive.node.ts | 160 +++++++++++++++++- 1 file changed, 157 insertions(+), 3 deletions(-) diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index 9e2a1c1a24..9b79b03825 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -81,15 +81,30 @@ export class Pipedrive implements INodeType { description: 'Get data of a deal', }, { - name: 'Get All Persons', - value: 'getAllPersons', - description: 'Get data of all persons', + name: 'Get Organization', + value: 'getOrganization', + description: 'Get data of an organization', }, { name: 'Get Person', value: 'getPerson', description: 'Get data of a person', }, + { + name: 'Get All Organizations', + value: 'getAllOrganizations', + description: 'Get data of all organizations', + }, + { + name: 'Get All Persons', + value: 'getAllPersons', + description: 'Get data of all persons', + }, + { + name: 'Get All Products', + value: 'getAllProducts', + description: 'Get data of all products', + }, { name: 'Update Activity', value: 'updateActivity', @@ -501,6 +516,46 @@ export class Pipedrive implements INodeType { }, + // ---------------------------------- + // getAllOrganizations + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAllOrganizations', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAllOrganizations', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, + + // ---------------------------------- // getAllPersons // ---------------------------------- @@ -540,6 +595,47 @@ export class Pipedrive implements INodeType { description: 'How many results to return.', }, + + // ---------------------------------- + // getAllProducts + // ---------------------------------- + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + operation: [ + 'getAllProducts', + ], + }, + }, + default: false, + description: 'If all results should be returned or only up to a given limit.', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getAllProducts', + ], + returnAll: [ + false, + ], + }, + }, + typeOptions: { + minValue: 1, + maxValue: 500, + }, + default: 100, + description: 'How many results to return.', + }, + + // ---------------------------------- // getActivity // ---------------------------------- @@ -580,6 +676,26 @@ export class Pipedrive implements INodeType { }, + // ---------------------------------- + // getOrganization + // ---------------------------------- + { + displayName: 'Organization ID', + name: 'organizationId', + type: 'number', + displayOptions: { + show: { + operation: [ + 'getOrganization' + ], + }, + }, + default: 0, + required: true, + description: 'ID of the organization to get.', + }, + + // ---------------------------------- // getPerson // ---------------------------------- @@ -1025,6 +1141,20 @@ export class Pipedrive implements INodeType { const personId = this.getNodeParameter('personId', i) as number; endpoint = `/persons/${personId}`; + } else if (operation === 'getAllOrganizations') { + // ---------------------------------- + // getAllOrganizations + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + endpoint = `/organizations`; + } else if (operation === 'getAllPersons') { // ---------------------------------- // getAllPersons @@ -1039,6 +1169,20 @@ export class Pipedrive implements INodeType { endpoint = `/persons`; + } else if (operation === 'getAllProducts') { + // ---------------------------------- + // getAllProducts + // ---------------------------------- + + requestMethod = 'GET'; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + endpoint = `/products`; + } else if (operation === 'getActivity') { // ---------------------------------- // getActivity @@ -1059,6 +1203,16 @@ export class Pipedrive implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/deals/${dealId}`; + } else if (operation === 'getOrganization') { + // ---------------------------------- + // getOrganization + // ---------------------------------- + + requestMethod = 'GET'; + + const organizationId = this.getNodeParameter('organizationId', i) as number; + endpoint = `/organizations/${organizationId}`; + } else if (operation === 'getPerson') { // ---------------------------------- // getPerson