From 6c50c84ab1fc52c150ab4d6a4486f1c03464cb5e Mon Sep 17 00:00:00 2001 From: Rodrigo Correia Date: Thu, 16 Sep 2021 14:09:19 -0300 Subject: [PATCH] Pipedrive - Get Activities from Deal Id --- .../nodes/Pipedrive/Pipedrive.node.ts | 126 +++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index 97b712e619..1ada18b0c3 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -118,6 +118,10 @@ export class Pipedrive implements INodeType { name: 'Deal', value: 'deal', }, + { + name: 'Deal Activity', + value: 'dealActivity', + }, { name: 'Deal Product', value: 'dealProduct', @@ -250,6 +254,27 @@ export class Pipedrive implements INodeType { description: 'The operation to perform.', }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + displayOptions: { + show: { + resource: [ + 'dealActivity', + ], + }, + }, + options: [ + { + name: 'Get All', + value: 'getAll', + description: 'Get all products in a deal', + }, + ], + default: 'getAll', + }, + { displayName: 'Operation', name: 'operation', @@ -3423,6 +3448,76 @@ export class Pipedrive implements INodeType { description: 'How many results to return.', }, + // ---------------------------------- + // dealActivities:getAll + // ---------------------------------- + { + displayName: 'Deal ID', + name: 'dealId', + type: 'options', + default: '', + typeOptions: { + loadOptionsMethod: 'getDeals', + }, + required: true, + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'dealActivity', + ], + }, + }, + description: 'The ID of the deal whose products to retrieve', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'getAll', + ], + resource: [ + 'dealActivity', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Done', + name: 'done', + type: 'options', + options: [ + { + name: 'Not done', + value: '0', + }, + { + name: 'Done', + value: '1', + }, + ], + default: '0', + description: 'Whether the activity is done or not.', + }, + { + displayName: 'Exclude Activity Ids', + name: 'exclude', + type: 'string', + typeOptions: { + rows: 3, + }, + default: '', + description: 'A comma separated Activity Ids, to exclude from result. Ex. 4, 9, 11, ...', + }, + ], + }, // ---------------------------------------- // lead: getAll // ---------------------------------------- @@ -4387,6 +4482,35 @@ export class Pipedrive implements INodeType { } + } else if (resource === 'dealActivity') { + + if (operation === 'getAll') { + // ---------------------------------- + // dealActivity: getAll + // ---------------------------------- + + requestMethod = 'GET'; + const dealId = this.getNodeParameter('dealId', i) as string; + + returnAll = this.getNodeParameter('returnAll', i) as boolean; + + if (returnAll === false) { + qs.limit = this.getNodeParameter('limit', i) as number; + } + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + + if (additionalFields.exclude) { + qs.exclude = (additionalFields.exclude as string); + } + + if (additionalFields.done) { + qs.done = parseInt(additionalFields.done as string); + } + + endpoint = `/deals/${dealId}/activities`; + + } } else if (resource === 'dealProduct') { if (operation === 'add') { @@ -4982,7 +5106,7 @@ export class Pipedrive implements INodeType { returnData.push(responseData.data as IDataObject); } } - } catch (error) { + } catch (error: any) { if (this.continueOnFail()) { if (resource === 'file' && operation === 'download') { items[i].json = { error: error.message };