From f8ad543af5c5d680d23d5dab861a6b3fe47b4ccc Mon Sep 17 00:00:00 2001 From: Bram Kn Date: Wed, 9 Aug 2023 11:54:20 +0200 Subject: [PATCH] feat(Pipedrive Node): Add option to update the file name and description (#6883) --- .../nodes/Pipedrive/Pipedrive.node.ts | 69 ++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index 5119a3ac8d..4d21400ecb 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -359,6 +359,12 @@ export class Pipedrive implements INodeType { description: 'Get data of a file', action: 'Get a file', }, + { + name: 'Update', + value: 'update', + description: 'Update file details', + action: 'update details of a file', + }, // { // name: 'Get All', // value: 'getAll', @@ -2023,6 +2029,57 @@ export class Pipedrive implements INodeType { description: 'ID of the file to get', }, + // ---------------------------------- + // file:update + // ---------------------------------- + { + displayName: 'File ID', + name: 'fileId', + type: 'number', + displayOptions: { + show: { + operation: ['update'], + resource: ['file'], + }, + }, + default: 0, + required: true, + description: 'ID of the file to update', + }, + { + displayName: 'Update Fields', + name: 'updateFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: ['update'], + resource: ['file'], + }, + }, + default: {}, + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The updated visible name of the file', + }, + { + displayName: 'Description', + name: 'description', + type: 'string', + default: '', + description: 'The updated description of the file', + }, + ], + }, + + // ---------------------------------- + // lead + // ---------------------------------- + // ---------------------------------------- // lead: create // ---------------------------------------- @@ -4380,6 +4437,16 @@ export class Pipedrive implements INodeType { const fileId = this.getNodeParameter('fileId', i) as number; endpoint = `/files/${fileId}`; + } else if (operation === 'update') { + // ---------------------------------- + // file:update + // ---------------------------------- + requestMethod = 'PUT'; + + const fileId = this.getNodeParameter('fileId', i) as number; + const updateFields = this.getNodeParameter('updateFields', i); + endpoint = `/files/${fileId}`; + addAdditionalFields(body, updateFields); } } else if (resource === 'note') { if (operation === 'create') { @@ -4842,7 +4909,7 @@ export class Pipedrive implements INodeType { responseData.data = []; } - if (operation === 'search' && responseData.data && responseData.data.items) { + if (operation === 'search' && responseData.data?.items) { responseData.data = responseData.data.items; const additionalFields = this.getNodeParameter('additionalFields', i); if (additionalFields.rawData !== true) {