mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -08:00
d6239d5bfb
* Update Compression node * Update Crypto node * Update DateTime node * Update EditImage node * Update EmailSend node * Update ExecuteWorkflow node * Update FTP node * Update Function node * Update FunctionItem node * Update ExecuteCommand node * Update OpenWeatherMap node * Update ReadBinaryFile node * Update ReadPdf node * Update RssFeedRead node & add URL validation * Update SpreadsheetFile node * Update Switch node * Update WriteBinaryFile node * Update Xml node * Update ActiveCampaign node * Update Airtable node * Update ApiTemplateIo node * Update Asana node * Update AwsLambda node * Update AwsSns node * Update AwsComprehend node * Update AwsRekognition node * Update AwsS3 node * Fix Error item * Update AwsSes node * Update AwsSqs node * Update Amqp node * Update Bitly node * Update Box node * Update Brandfetch node * Update CircleCi node * Update Clearbit node * Update ClickUp node * Update Cockpit node * Update CoinGecko node * Update Contentful node * Update ConvertKit node * Update Cortex node * Update CustomerIo node * Update DeepL node * Update Demio node * Update Disqus node * Update Drift node * Update Dropbox node * Update GetResponse node * Refactor & Update Ghost node * Update Github node * Update Gitlab node * Update GoogleAnalytics node * Update GoogleBooks node * Update GoogleCalendar node * Update GoogleDrive node * Update Gmail node * Update GoogleSheets node * Update GoogleSlides node * Update GoogleTasks node * Update Gotify node * Update GraphQL node * Update HackerNews node * Update Harvest node * Update HtmlExtract node * Update Hubspot node * Update Hunter node * Update Intercom node * Update Kafka node * Refactor & update Line node * Update LinkedIn node * Update Mailchimp node * Update Mandrill node * Update Matrix node * Update Mautic node * Update Medium node * Update MessageBird node * Update Mindee node * Update Mocean node * Update MondayCom node * Update MicrosoftExcel node * Update MicrosoftOneDrive node * Update MicrosoftOutlook node * Update Affinity node * Update Chargebee node * Update Discourse node * Update Freshdesk node * Update YouTube node * Update InvoiceNinja node * Update MailerLite node * Update Mailgun node * Update Mailjet node * Update Mattermost node * Update Nasa node * Update NextCloud node * Update OpenThesaurus node * Update Orbit node * Update PagerDuty node * Update PayPal node * Update Peekalink node * Update Phantombuster node * Update PostHog node * Update ProfitWell node * Refactor & Update Pushbullet node * Update QuickBooks node * Update Raindrop node * Update Reddit node * Update Rocketchat node * Update S3 node * Update Salesforce node * Update SendGrid node * Update SentryIo node * Update Shopify node * Update Signl4 node * Update Slack node * Update Spontit node * Update Spotify node * Update Storyblok node * Refactor & Update Strapi node * Refactor & Update Strava node * Update Taiga node * Refactor & update Tapfiliate node * Update Telegram node * Update TheHive node * Update Todoist node * Update TravisCi node * Update Trello node * Update Twilio node * Update Twist node * Update Twitter node * Update Uplead node * Update UProc node * Update Vero node * Update Webflow node * Update Wekan node * Update Wordpress node * Update Xero node * Update Yourls node * Update Zendesk node * Update ZohoCrm node * Refactor & Update Zoom node * Update Zulip node * Update Clockify node * Update MongoDb node * Update MySql node * Update MicrosoftTeams node * Update Stackby node * Refactor Discourse node * Support corner-case in Github node update * Support corner-case in Gitlab node update * Refactor & Update GoogleContacts node * Refactor Mindee node * Update Coda node * Lint fixes * Update Beeminder node * Update Google Firebase RealtimeDatabase node * Update HelpScout node * Update Mailcheck node * Update Paddle node * Update Pipedrive node * Update Pushover node * Update Segment node * Refactor & Update Vonage node * Added new conditions to warnings on execute batch cmd * Added keep only properties flag * Fixed code for keep only props * Added dependencies for image editing Co-authored-by: dali <servfrdali@yahoo.fr>
697 lines
21 KiB
TypeScript
697 lines
21 KiB
TypeScript
import {
|
|
IExecuteFunctions,
|
|
} from 'n8n-core';
|
|
|
|
import {
|
|
IDataObject,
|
|
ILoadOptionsFunctions,
|
|
INodeExecutionData,
|
|
INodePropertyOptions,
|
|
INodeType,
|
|
INodeTypeDescription,
|
|
NodeOperationError,
|
|
} from 'n8n-workflow';
|
|
|
|
import {
|
|
apiRequest,
|
|
} from './GenericFunctions';
|
|
|
|
import {
|
|
boardFields,
|
|
boardOperations,
|
|
} from './BoardDescription';
|
|
|
|
import {
|
|
cardFields,
|
|
cardOperations,
|
|
} from './CardDescription';
|
|
|
|
import {
|
|
cardCommentFields,
|
|
cardCommentOperations,
|
|
} from './CardCommentDescription';
|
|
|
|
import {
|
|
checklistFields,
|
|
checklistOperations,
|
|
} from './ChecklistDescription';
|
|
|
|
import {
|
|
checklistItemFields,
|
|
checklistItemOperations,
|
|
} from './ChecklistItemDescription';
|
|
|
|
import {
|
|
listFields,
|
|
listOperations,
|
|
} from './ListDescription';
|
|
|
|
// https://wekan.github.io/api/v4.41/
|
|
|
|
export class Wekan implements INodeType {
|
|
description: INodeTypeDescription = {
|
|
displayName: 'Wekan',
|
|
name: 'wekan',
|
|
icon: 'file:wekan.png',
|
|
group: ['transform'],
|
|
version: 1,
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
description: 'Consume Wekan API',
|
|
defaults: {
|
|
name: 'Wekan',
|
|
color: '#006581',
|
|
},
|
|
inputs: ['main'],
|
|
outputs: ['main'],
|
|
credentials: [
|
|
{
|
|
name: 'wekanApi',
|
|
required: true,
|
|
},
|
|
],
|
|
properties: [
|
|
{
|
|
displayName: 'Resource',
|
|
name: 'resource',
|
|
type: 'options',
|
|
options: [
|
|
{
|
|
name: 'Board',
|
|
value: 'board',
|
|
},
|
|
{
|
|
name: 'Card',
|
|
value: 'card',
|
|
},
|
|
{
|
|
name: 'Card Comment',
|
|
value: 'cardComment',
|
|
},
|
|
{
|
|
name: 'Checklist',
|
|
value: 'checklist',
|
|
},
|
|
{
|
|
name: 'Checklist Item',
|
|
value: 'checklistItem',
|
|
},
|
|
{
|
|
name: 'List',
|
|
value: 'list',
|
|
},
|
|
],
|
|
default: 'card',
|
|
description: 'The resource to operate on.',
|
|
},
|
|
|
|
// ----------------------------------
|
|
// operations
|
|
// ----------------------------------
|
|
...boardOperations,
|
|
...cardOperations,
|
|
...cardCommentOperations,
|
|
...checklistOperations,
|
|
...checklistItemOperations,
|
|
...listOperations,
|
|
|
|
// ----------------------------------
|
|
// fields
|
|
// ----------------------------------
|
|
...boardFields,
|
|
...cardFields,
|
|
...cardCommentFields,
|
|
...checklistFields,
|
|
...checklistItemFields,
|
|
...listFields,
|
|
],
|
|
};
|
|
|
|
methods = {
|
|
loadOptions: {
|
|
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const users = await apiRequest.call(this, 'GET', 'users', {}, {});
|
|
for (const user of users) {
|
|
returnData.push({
|
|
name: user.username,
|
|
value: user._id,
|
|
});
|
|
}
|
|
return returnData;
|
|
},
|
|
async getBoards(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const user = await apiRequest.call(this, 'GET', `user`, {}, {});
|
|
const boards = await apiRequest.call(this, 'GET', `users/${user._id}/boards`, {}, {});
|
|
for (const board of boards) {
|
|
returnData.push({
|
|
name: board.title,
|
|
value: board._id,
|
|
});
|
|
}
|
|
return returnData;
|
|
},
|
|
async getLists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const boardId = this.getCurrentNodeParameter('boardId') as string;
|
|
const lists = await apiRequest.call(this, 'GET', `boards/${boardId}/lists`, {}, {});
|
|
for (const list of lists) {
|
|
returnData.push({
|
|
name: list.title,
|
|
value: list._id,
|
|
});
|
|
}
|
|
return returnData;
|
|
},
|
|
async getSwimlanes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const boardId = this.getCurrentNodeParameter('boardId') as string;
|
|
const swimlanes = await apiRequest.call(this, 'GET', `boards/${boardId}/swimlanes`, {}, {});
|
|
for (const swimlane of swimlanes) {
|
|
returnData.push({
|
|
name: swimlane.title,
|
|
value: swimlane._id,
|
|
});
|
|
}
|
|
return returnData;
|
|
},
|
|
async getCards(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const boardId = this.getCurrentNodeParameter('boardId') as string;
|
|
const listId = this.getCurrentNodeParameter('listId') as string;
|
|
const cards = await apiRequest.call(this, 'GET', `boards/${boardId}/lists/${listId}/cards`, {}, {});
|
|
for (const card of cards) {
|
|
returnData.push({
|
|
name: card.title,
|
|
value: card._id,
|
|
});
|
|
}
|
|
return returnData;
|
|
},
|
|
async getChecklists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const boardId = this.getCurrentNodeParameter('boardId') as string;
|
|
const cardId = this.getCurrentNodeParameter('cardId') as string;
|
|
const checklists = await apiRequest.call(this, 'GET', `boards/${boardId}/cards/${cardId}/checklists`, {}, {});
|
|
for (const checklist of checklists) {
|
|
returnData.push({
|
|
name: checklist.title,
|
|
value: checklist._id,
|
|
});
|
|
}
|
|
return returnData;
|
|
},
|
|
async getChecklistItems(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const boardId = this.getCurrentNodeParameter('boardId') as string;
|
|
const cardId = this.getCurrentNodeParameter('cardId') as string;
|
|
const checklistId = this.getCurrentNodeParameter('checklistId') as string;
|
|
const checklist = await apiRequest.call(this, 'GET', `boards/${boardId}/cards/${cardId}/checklists/${checklistId}`, {}, {});
|
|
for (const item of checklist.items) {
|
|
returnData.push({
|
|
name: item.title,
|
|
value: item._id,
|
|
});
|
|
}
|
|
return returnData;
|
|
},
|
|
async getComments(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
const returnData: INodePropertyOptions[] = [];
|
|
const boardId = this.getCurrentNodeParameter('boardId') as string;
|
|
const cardId = this.getCurrentNodeParameter('cardId') as string;
|
|
const comments = await apiRequest.call(this, 'GET', `boards/${boardId}/cards/${cardId}/comments`, {}, {});
|
|
for (const comment of comments) {
|
|
returnData.push({
|
|
name: comment.comment,
|
|
value: comment._id,
|
|
});
|
|
}
|
|
return returnData;
|
|
},
|
|
},
|
|
};
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
const items = this.getInputData();
|
|
const returnData: IDataObject[] = [];
|
|
let returnAll;
|
|
let limit;
|
|
|
|
const operation = this.getNodeParameter('operation', 0) as string;
|
|
const resource = this.getNodeParameter('resource', 0) as string;
|
|
|
|
// For Post
|
|
let body: IDataObject;
|
|
// For Query string
|
|
let qs: IDataObject;
|
|
|
|
let requestMethod: string;
|
|
let endpoint: string;
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
try {
|
|
requestMethod = 'GET';
|
|
endpoint = '';
|
|
body = {};
|
|
qs = {};
|
|
|
|
if (resource === 'board') {
|
|
|
|
if (operation === 'create') {
|
|
// ----------------------------------
|
|
// create
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'POST';
|
|
endpoint = 'boards';
|
|
|
|
body.title = this.getNodeParameter('title', i) as string;
|
|
body.owner = this.getNodeParameter('owner', i) as string;
|
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
Object.assign(body, additionalFields);
|
|
|
|
} else if (operation === 'delete') {
|
|
// ----------------------------------
|
|
// delete
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}`;
|
|
|
|
} else if (operation === 'get') {
|
|
// ----------------------------------
|
|
// get
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}`;
|
|
|
|
} else if (operation === 'getAll') {
|
|
// ----------------------------------
|
|
// getAll
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const userId = this.getNodeParameter('IdUser', i) as string;
|
|
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
|
|
|
endpoint = `users/${userId}/boards`;
|
|
|
|
} else {
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
|
}
|
|
|
|
} else if (resource === 'card') {
|
|
|
|
if (operation === 'create') {
|
|
// ----------------------------------
|
|
// create
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'POST';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const listId = this.getNodeParameter('listId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/lists/${listId}/cards`;
|
|
|
|
body.title = this.getNodeParameter('title', i) as string;
|
|
body.swimlaneId = this.getNodeParameter('swimlaneId', i) as string;
|
|
body.authorId = this.getNodeParameter('authorId', i) as string;
|
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
Object.assign(body, additionalFields);
|
|
|
|
} else if (operation === 'delete') {
|
|
// ----------------------------------
|
|
// delete
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const listId = this.getNodeParameter('listId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/lists/${listId}/cards/${cardId}`;
|
|
|
|
} else if (operation === 'get') {
|
|
// ----------------------------------
|
|
// get
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const listId = this.getNodeParameter('listId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/lists/${listId}/cards/${cardId}`;
|
|
|
|
} else if (operation === 'getAll') {
|
|
// ----------------------------------
|
|
// getAll
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const fromObject = this.getNodeParameter('fromObject', i) as string;
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
|
|
|
if (fromObject === 'list') {
|
|
const listId = this.getNodeParameter('listId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/lists/${listId}/cards`;
|
|
}
|
|
|
|
if (fromObject === 'swimlane') {
|
|
const swimlaneId = this.getNodeParameter('swimlaneId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/swimlanes/${swimlaneId}/cards`;
|
|
}
|
|
|
|
} else if (operation === 'update') {
|
|
// ----------------------------------
|
|
// update
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'PUT';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const listId = this.getNodeParameter('listId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/lists/${listId}/cards/${cardId}`;
|
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
|
Object.assign(body, updateFields);
|
|
|
|
} else {
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
|
}
|
|
|
|
} else if (resource === 'cardComment') {
|
|
|
|
if (operation === 'create') {
|
|
// ----------------------------------
|
|
// create
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'POST';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/comments`;
|
|
|
|
body.authorId = this.getNodeParameter('authorId', i) as string;
|
|
body.comment = this.getNodeParameter('comment', i) as string;
|
|
|
|
} else if (operation === 'delete') {
|
|
// ----------------------------------
|
|
// delete
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const commentId = this.getNodeParameter('commentId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/comments/${commentId}`;
|
|
|
|
} else if (operation === 'get') {
|
|
// ----------------------------------
|
|
// get
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const commentId = this.getNodeParameter('commentId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/comments/${commentId}`;
|
|
|
|
} else if (operation === 'getAll') {
|
|
// ----------------------------------
|
|
// getAll
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/comments`;
|
|
|
|
} else {
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
|
}
|
|
|
|
} else if (resource === 'list') {
|
|
|
|
if (operation === 'create') {
|
|
// ----------------------------------
|
|
// create
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'POST';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/lists`;
|
|
|
|
body.title = this.getNodeParameter('title', i) as string;
|
|
|
|
} else if (operation === 'delete') {
|
|
// ----------------------------------
|
|
// delete
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const listId = this.getNodeParameter('listId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/lists/${listId}`;
|
|
|
|
} else if (operation === 'get') {
|
|
// ----------------------------------
|
|
// get
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const listId = this.getNodeParameter('listId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/lists/${listId}`;
|
|
|
|
} else if (operation === 'getAll') {
|
|
// ----------------------------------
|
|
// getAll
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
|
|
|
endpoint = `boards/${boardId}/lists`;
|
|
|
|
} else {
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
|
}
|
|
|
|
} else if (resource === 'checklist') {
|
|
|
|
if (operation === 'create') {
|
|
// ----------------------------------
|
|
// create
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'POST';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists`;
|
|
|
|
body.title = this.getNodeParameter('title', i) as string;
|
|
|
|
body.items = this.getNodeParameter('items', i) as string[];
|
|
|
|
} else if (operation === 'delete') {
|
|
// ----------------------------------
|
|
// delete
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}`;
|
|
|
|
} else if (operation === 'get') {
|
|
// ----------------------------------
|
|
// get
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}`;
|
|
|
|
} else if (operation === 'getAll') {
|
|
// ----------------------------------
|
|
// getAll
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
|
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists`;
|
|
|
|
} else if (operation === 'getCheckItem') {
|
|
// ----------------------------------
|
|
// getCheckItem
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
|
const itemId = this.getNodeParameter('itemId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`;
|
|
|
|
} else if (operation === 'deleteCheckItem') {
|
|
// ----------------------------------
|
|
// deleteCheckItem
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
|
const itemId = this.getNodeParameter('itemId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`;
|
|
|
|
} else if (operation === 'updateCheckItem') {
|
|
// ----------------------------------
|
|
// updateCheckItem
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'PUT';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
|
const itemId = this.getNodeParameter('itemId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`;
|
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
|
Object.assign(body, updateFields);
|
|
|
|
|
|
|
|
} else {
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
|
}
|
|
} else if (resource === 'checklistItem') {
|
|
|
|
if (operation === 'get') {
|
|
// ----------------------------------
|
|
// get
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'GET';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
|
const itemId = this.getNodeParameter('checklistItemId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`;
|
|
|
|
} else if (operation === 'delete') {
|
|
// ----------------------------------
|
|
// delete
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
|
const itemId = this.getNodeParameter('checklistItemId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`;
|
|
|
|
} else if (operation === 'update') {
|
|
// ----------------------------------
|
|
// update
|
|
// ----------------------------------
|
|
|
|
requestMethod = 'PUT';
|
|
|
|
const boardId = this.getNodeParameter('boardId', i) as string;
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
|
const itemId = this.getNodeParameter('checklistItemId', i) as string;
|
|
|
|
endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`;
|
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
|
Object.assign(body, updateFields);
|
|
}
|
|
}
|
|
let responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
|
|
|
if (returnAll === false) {
|
|
limit = this.getNodeParameter('limit', i) as number;
|
|
responseData = responseData.splice(0, limit);
|
|
}
|
|
|
|
if (Array.isArray(responseData)) {
|
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
|
} else {
|
|
returnData.push(responseData as IDataObject);
|
|
}
|
|
} catch (error) {
|
|
if (this.continueOnFail()) {
|
|
returnData.push({ error: error.message });
|
|
continue;
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
return [this.helpers.returnJsonArray(returnData)];
|
|
}
|
|
}
|