From 29cb669a6b42fee49cea5d59f7c722915e85a6fb Mon Sep 17 00:00:00 2001 From: trojanh Date: Mon, 20 Jan 2020 19:07:27 +0530 Subject: [PATCH] Add checkItem API to get, update and delete --- .../nodes-base/nodes/Trello/Trello.node.ts | 249 +++++++++++++++++- 1 file changed, 248 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Trello/Trello.node.ts b/packages/nodes-base/nodes/Trello/Trello.node.ts index 13144678b6..4364552873 100644 --- a/packages/nodes-base/nodes/Trello/Trello.node.ts +++ b/packages/nodes-base/nodes/Trello/Trello.node.ts @@ -1512,17 +1512,32 @@ export class Trello implements INodeType { { name: 'Delete', value: 'delete', - description: 'Delete a board', + description: 'Delete a checklist', + }, + { + name: 'Delete CheckItem', + value: 'deleteCheckItem', + description: 'Delete a checklist item', }, { name: 'Get', value: 'get', description: 'Get the data of a checklist', }, + { + name: 'Get CheckItem', + value: 'getCheckItem', + description: 'Get a specific checkItem on a card', + }, { name: 'Get All', value: 'getAll', description: 'Returns all checklists for the card', + }, + { + name: 'Update CheckItem', + value: 'updateCheckItem', + description: 'Update an item in a checklist on a card.', } ], default: 'getAll', @@ -1739,6 +1754,199 @@ export class Trello implements INodeType { ], }, + // ---------------------------------- + // checklist:deleteCheckItem + // ---------------------------------- + { + displayName: 'Card ID', + name: 'cardId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'deleteCheckItem', + ], + resource: [ + 'checklist', + ], + }, + }, + description: 'The ID of the card that checklist belongs to.', + }, + { + displayName: 'CheckItem ID', + name: 'checkItemId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'deleteCheckItem', + ], + resource: [ + 'checklist', + ], + }, + }, + description: 'The ID of the checklist to delete.', + }, + + // ---------------------------------- + // checklist:getCheckItem + // ---------------------------------- + { + displayName: 'Card ID', + name: 'cardId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'getCheckItem', + ], + resource: [ + 'checklist', + ], + }, + }, + description: 'The ID of the card that checklist belongs to.', + }, + { + displayName: 'CheckItem ID', + name: 'checkItemId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'getCheckItem', + ], + resource: [ + 'checklist', + ], + }, + }, + description: 'The ID of the checklist to get.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'getCheckItem', + ], + resource: [ + 'checklist', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Fields', + name: 'fields', + type: 'string', + default: 'all', + description: 'Fields to return. Either "all" or a comma-separated list of fields.', + }, + ], + }, + + // ---------------------------------- + // checklist:updateCheckItem + // ---------------------------------- + { + displayName: 'Card ID', + name: 'cardId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'updateCheckItem', + ], + resource: [ + 'checklist', + ], + }, + }, + description: 'The ID of the card that checklist belongs to.', + }, + { + displayName: 'CheckItem ID', + name: 'checkItemId', + type: 'string', + default: '', + required: true, + displayOptions: { + show: { + operation: [ + 'updateCheckItem', + ], + resource: [ + 'checklist', + ], + }, + }, + description: 'The ID of the checklist item to update.', + }, + { + displayName: 'Additional Fields', + name: 'additionalFields', + type: 'collection', + placeholder: 'Add Field', + displayOptions: { + show: { + operation: [ + 'updateCheckItem', + ], + resource: [ + 'checklist', + ], + }, + }, + default: {}, + options: [ + { + displayName: 'Name', + name: 'name', + type: 'string', + default: '', + description: 'The new name for the checklist item.', + }, + { + displayName: 'State', + name: 'state', + type: 'string', + default: '', + description: 'One of: complete, incomplete', + }, + { + displayName: 'Checklist ID', + name: 'checklistId', + type: 'string', + default: '', + description: 'The ID of the checklist this item is in', + }, + { + displayName: 'Position', + name: 'pos', + type: 'string', + default: '', + description: 'The position of the checklist on the card. One of: top, bottom, or a positive number.', + }, + ], + }, + ], @@ -2068,6 +2276,45 @@ export class Trello implements INodeType { endpoint = `cards/${cardId}/checklists`; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'getCheckItem') { + // ---------------------------------- + // getCheckItem + // ---------------------------------- + + requestMethod = 'GET'; + + const cardId = this.getNodeParameter('cardId', i) as string; + const checkItemId = this.getNodeParameter('checkItemId', i) as string; + + endpoint = `cards/${cardId}/checkItem/${checkItemId}`; + + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; + Object.assign(qs, additionalFields); + } else if (operation === 'deleteCheckItem') { + // ---------------------------------- + // deleteCheckItem + // ---------------------------------- + + requestMethod = 'DELETE'; + + const cardId = this.getNodeParameter('cardId', i) as string; + const checkItemId = this.getNodeParameter('checkItemId', i) as string; + + endpoint = `cards/${cardId}/checkItem/${checkItemId}`; + } else if (operation === 'updateCheckItem') { + // ---------------------------------- + // updateCheckItem + // ---------------------------------- + + requestMethod = 'PUT'; + + const cardId = this.getNodeParameter('cardId', i) as string; + const checkItemId = this.getNodeParameter('checkItemId', i) as string; + + endpoint = `cards/${cardId}/checkItem/${checkItemId}`; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); } else {