2020-08-24 17:55:57 -07:00
|
|
|
import {
|
|
|
|
IExecuteFunctions,
|
|
|
|
} from 'n8n-core';
|
|
|
|
|
2019-07-12 08:54:15 -07:00
|
|
|
import {
|
|
|
|
IDataObject,
|
|
|
|
INodeExecutionData,
|
|
|
|
INodeType,
|
2020-10-01 05:01:39 -07:00
|
|
|
INodeTypeDescription,
|
2021-04-16 09:33:36 -07:00
|
|
|
NodeOperationError,
|
2019-07-12 08:54:15 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
2020-08-24 17:55:57 -07:00
|
|
|
import {
|
|
|
|
apiRequest,
|
2021-01-19 06:09:03 -08:00
|
|
|
apiRequestAllItems,
|
2020-08-24 17:55:57 -07:00
|
|
|
} from './GenericFunctions';
|
|
|
|
|
|
|
|
import {
|
|
|
|
attachmentFields,
|
2020-10-01 05:01:39 -07:00
|
|
|
attachmentOperations,
|
2020-08-24 17:55:57 -07:00
|
|
|
} from './AttachmentDescription';
|
|
|
|
|
|
|
|
import {
|
|
|
|
boardFields,
|
2020-10-01 05:01:39 -07:00
|
|
|
boardOperations,
|
2020-08-24 17:55:57 -07:00
|
|
|
} from './BoardDescription';
|
|
|
|
|
2022-05-15 10:48:17 -07:00
|
|
|
import {
|
|
|
|
boardMemberFields,
|
|
|
|
boardMemberOperations,
|
|
|
|
} from './BoardMemberDescription';
|
|
|
|
|
2020-08-24 17:55:57 -07:00
|
|
|
import {
|
|
|
|
cardFields,
|
2020-10-01 05:01:39 -07:00
|
|
|
cardOperations,
|
2020-08-24 17:55:57 -07:00
|
|
|
} from './CardDescription';
|
|
|
|
|
|
|
|
import {
|
|
|
|
cardCommentFields,
|
2020-10-01 05:01:39 -07:00
|
|
|
cardCommentOperations,
|
2020-08-24 17:55:57 -07:00
|
|
|
} from './CardCommentDescription';
|
|
|
|
|
|
|
|
import {
|
|
|
|
checklistFields,
|
2020-10-01 05:01:39 -07:00
|
|
|
checklistOperations,
|
2020-08-24 17:55:57 -07:00
|
|
|
} from './ChecklistDescription';
|
|
|
|
|
|
|
|
import {
|
|
|
|
labelFields,
|
2020-10-01 05:01:39 -07:00
|
|
|
labelOperations,
|
2020-08-24 17:55:57 -07:00
|
|
|
} from './LabelDescription';
|
|
|
|
|
|
|
|
import {
|
|
|
|
listFields,
|
2020-10-01 05:01:39 -07:00
|
|
|
listOperations,
|
2020-08-24 17:55:57 -07:00
|
|
|
} from './ListDescription';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
|
|
|
export class Trello implements INodeType {
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
displayName: 'Trello',
|
|
|
|
name: 'trello',
|
2021-01-19 06:09:03 -08:00
|
|
|
icon: 'file:trello.svg',
|
2019-07-12 08:54:15 -07:00
|
|
|
group: ['transform'],
|
|
|
|
version: 1,
|
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
|
|
description: 'Create, change and delete boards and cards',
|
|
|
|
defaults: {
|
|
|
|
name: 'Trello',
|
|
|
|
},
|
|
|
|
inputs: ['main'],
|
|
|
|
outputs: ['main'],
|
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'trelloApi',
|
|
|
|
required: true,
|
2020-08-24 17:55:57 -07:00
|
|
|
},
|
2019-07-12 08:54:15 -07:00
|
|
|
],
|
|
|
|
properties: [
|
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
noDataExpression: true,
|
2019-07-12 08:54:15 -07:00
|
|
|
options: [
|
2020-01-17 10:20:34 -08:00
|
|
|
{
|
2020-01-23 20:20:38 -08:00
|
|
|
name: 'Attachment',
|
2020-10-22 06:46:03 -07:00
|
|
|
value: 'attachment',
|
2020-01-17 10:20:34 -08:00
|
|
|
},
|
2019-07-12 08:54:15 -07:00
|
|
|
{
|
|
|
|
name: 'Board',
|
|
|
|
value: 'board',
|
|
|
|
},
|
2022-05-15 10:48:17 -07:00
|
|
|
{
|
|
|
|
name: 'Board Member',
|
|
|
|
value: 'boardMember',
|
|
|
|
},
|
2019-07-12 08:54:15 -07:00
|
|
|
{
|
|
|
|
name: 'Card',
|
|
|
|
value: 'card',
|
|
|
|
},
|
2020-08-24 17:55:57 -07:00
|
|
|
{
|
|
|
|
name: 'Card Comment',
|
|
|
|
value: 'cardComment',
|
|
|
|
},
|
2020-01-20 05:10:19 -08:00
|
|
|
{
|
2020-01-23 20:20:38 -08:00
|
|
|
name: 'Checklist',
|
|
|
|
value: 'checklist',
|
2020-01-20 05:10:19 -08:00
|
|
|
},
|
2020-01-20 07:28:51 -08:00
|
|
|
{
|
2020-01-23 20:20:38 -08:00
|
|
|
name: 'Label',
|
2020-10-22 06:46:03 -07:00
|
|
|
value: 'label',
|
2020-01-23 20:20:38 -08:00
|
|
|
},
|
2019-07-12 08:54:15 -07:00
|
|
|
{
|
|
|
|
name: 'List',
|
|
|
|
value: 'list',
|
2020-01-17 06:46:13 -08:00
|
|
|
},
|
2019-07-12 08:54:15 -07:00
|
|
|
],
|
|
|
|
default: 'card',
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
2020-01-24 04:28:05 -08:00
|
|
|
// operations
|
2019-07-12 08:54:15 -07:00
|
|
|
// ----------------------------------
|
2020-01-24 04:28:05 -08:00
|
|
|
...attachmentOperations,
|
|
|
|
...boardOperations,
|
2022-05-15 10:48:17 -07:00
|
|
|
...boardMemberOperations,
|
2020-01-24 04:28:05 -08:00
|
|
|
...cardOperations,
|
2020-08-24 17:55:57 -07:00
|
|
|
...cardCommentOperations,
|
2020-01-24 04:28:05 -08:00
|
|
|
...checklistOperations,
|
|
|
|
...labelOperations,
|
|
|
|
...listOperations,
|
2019-07-12 08:54:15 -07:00
|
|
|
|
|
|
|
// ----------------------------------
|
2020-01-24 04:28:05 -08:00
|
|
|
// fields
|
2019-07-12 08:54:15 -07:00
|
|
|
// ----------------------------------
|
2020-01-24 04:28:05 -08:00
|
|
|
...attachmentFields,
|
|
|
|
...boardFields,
|
2022-05-15 10:48:17 -07:00
|
|
|
...boardMemberFields,
|
2020-01-24 04:28:05 -08:00
|
|
|
...cardFields,
|
2020-08-24 17:55:57 -07:00
|
|
|
...cardCommentFields,
|
2020-01-24 04:28:05 -08:00
|
|
|
...checklistFields,
|
|
|
|
...labelFields,
|
2020-10-22 06:46:03 -07:00
|
|
|
...listFields,
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2020-01-20 07:28:51 -08:00
|
|
|
],
|
2019-07-12 08:54:15 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
const items = this.getInputData();
|
|
|
|
const returnData: IDataObject[] = [];
|
|
|
|
|
|
|
|
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;
|
2021-01-19 06:09:03 -08:00
|
|
|
let returnAll = false;
|
|
|
|
let responseData;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
2021-07-19 23:58:54 -07:00
|
|
|
try {
|
|
|
|
requestMethod = 'GET';
|
|
|
|
endpoint = '';
|
|
|
|
body = {};
|
|
|
|
qs = {};
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (resource === 'board') {
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// create
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
|
|
|
endpoint = 'boards';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
qs.name = this.getNodeParameter('name', i) as string;
|
|
|
|
qs.desc = this.getNodeParameter('description', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------
|
|
|
|
// delete
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'DELETE';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `boards/${id}`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------
|
|
|
|
// get
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `boards/${id}`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'update') {
|
|
|
|
// ----------------------------------
|
|
|
|
// update
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'PUT';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `boards/${id}`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, updateFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
2022-05-15 10:48:17 -07:00
|
|
|
} else if (resource === 'boardMember') {
|
|
|
|
if (operation === 'getAll') {
|
|
|
|
// ----------------------------------
|
|
|
|
// getAll
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'GET';
|
|
|
|
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
|
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
|
|
|
if (returnAll === false) {
|
|
|
|
qs.limit = this.getNodeParameter('limit', i) as number;
|
|
|
|
}
|
|
|
|
|
|
|
|
endpoint = `boards/${id}/members`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2022-05-15 10:48:17 -07:00
|
|
|
} else if (operation === 'add') {
|
|
|
|
// ----------------------------------
|
|
|
|
// add
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'PUT';
|
|
|
|
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
|
|
|
const idMember = this.getNodeParameter('idMember', i) as string;
|
|
|
|
|
|
|
|
endpoint = `boards/${id}/members/${idMember}`;
|
|
|
|
|
|
|
|
qs.type = this.getNodeParameter('type', i) as string;
|
|
|
|
qs.allowBillableGuest = this.getNodeParameter('additionalFields.allowBillableGuest', i, false) as boolean;
|
|
|
|
|
|
|
|
} else if (operation === 'invite') {
|
|
|
|
// ----------------------------------
|
|
|
|
// invite
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'PUT';
|
|
|
|
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
|
|
|
|
|
|
|
endpoint = `boards/${id}/members`;
|
|
|
|
|
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
|
|
|
|
qs.email = this.getNodeParameter('email', i) as string;
|
|
|
|
qs.type = additionalFields.type as string;
|
|
|
|
body.fullName = additionalFields.fullName as string;
|
|
|
|
} else if (operation === 'remove') {
|
|
|
|
// ----------------------------------
|
|
|
|
// remove
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
requestMethod = 'DELETE';
|
|
|
|
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
|
|
|
const idMember = this.getNodeParameter('idMember', i) as string;
|
|
|
|
|
|
|
|
endpoint = `boards/${id}/members/${idMember}`;
|
|
|
|
|
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
|
2022-05-15 10:48:17 -07:00
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (resource === 'card') {
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// create
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
|
|
|
endpoint = 'cards';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
qs.idList = this.getNodeParameter('listId', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
qs.name = this.getNodeParameter('name', i) as string;
|
|
|
|
qs.desc = this.getNodeParameter('description', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------
|
|
|
|
// delete
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'DELETE';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${id}`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------
|
|
|
|
// get
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${id}`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'update') {
|
|
|
|
// ----------------------------------
|
|
|
|
// update
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'PUT';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${id}`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, updateFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (resource === 'cardComment') {
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// create
|
|
|
|
// ----------------------------------
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
qs.text = this.getNodeParameter('text', i) as string;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/actions/comments`;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------
|
|
|
|
// delete
|
|
|
|
// ----------------------------------
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'DELETE';
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const commentId = this.getNodeParameter('commentId', i) as string;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `/cards/${cardId}/actions/${commentId}/comments`;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'update') {
|
|
|
|
// ----------------------------------
|
|
|
|
// update
|
|
|
|
// ----------------------------------
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'PUT';
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const commentId = this.getNodeParameter('commentId', i) as string;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
qs.text = this.getNodeParameter('text', i) as string;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/actions/${commentId}/comments`;
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
2020-08-24 17:55:57 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (resource === 'list') {
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (operation === 'archive') {
|
|
|
|
// ----------------------------------
|
|
|
|
// archive
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'PUT';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
|
|
|
qs.value = this.getNodeParameter('archive', i) as boolean;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `lists/${id}/closed`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// create
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
|
|
|
endpoint = 'lists';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
qs.idBoard = this.getNodeParameter('idBoard', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
qs.name = this.getNodeParameter('name', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------
|
|
|
|
// get
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `lists/${id}`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'getAll') {
|
|
|
|
// ----------------------------------
|
|
|
|
// getAll
|
|
|
|
// ----------------------------------
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (returnAll === false) {
|
|
|
|
qs.limit = this.getNodeParameter('limit', i) as number;
|
|
|
|
}
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `boards/${id}/lists`;
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'getCards') {
|
|
|
|
// ----------------------------------
|
|
|
|
// getCards
|
|
|
|
// ----------------------------------
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (returnAll === false) {
|
|
|
|
qs.limit = this.getNodeParameter('limit', i) as number;
|
|
|
|
}
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `lists/${id}/cards`;
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'update') {
|
|
|
|
// ----------------------------------
|
|
|
|
// update
|
|
|
|
// ----------------------------------
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'PUT';
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `lists/${id}`;
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, updateFields);
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (resource === 'attachment') {
|
2020-01-16 05:54:01 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// create
|
|
|
|
// ----------------------------------
|
2020-01-17 10:20:34 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
2020-01-16 05:54:01 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const url = this.getNodeParameter('url', i) as string;
|
2020-01-16 05:54:01 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
Object.assign(qs, {
|
|
|
|
url,
|
|
|
|
});
|
2020-01-16 05:54:01 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-17 10:20:34 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/attachments`;
|
2020-01-17 10:20:34 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------
|
|
|
|
// delete
|
|
|
|
// ----------------------------------
|
2020-01-17 10:20:34 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'DELETE';
|
2020-01-16 06:36:45 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-16 06:36:45 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/attachments/${id}`;
|
2020-01-16 06:36:45 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------
|
|
|
|
// get
|
|
|
|
// ----------------------------------
|
2020-01-16 06:11:54 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2020-01-16 06:11:54 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-16 06:11:54 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/attachments/${id}`;
|
2020-01-16 06:11:54 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-16 06:11:54 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'getAll') {
|
|
|
|
// ----------------------------------
|
|
|
|
// getAll
|
|
|
|
// ----------------------------------
|
2020-01-16 06:36:45 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2020-01-16 06:36:45 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
2020-01-16 06:36:45 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/attachments`;
|
2020-01-16 06:36:45 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
2020-01-23 20:20:38 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (resource === 'checklist') {
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// create
|
|
|
|
// ----------------------------------
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const name = this.getNodeParameter('name', i) as string;
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
Object.assign(qs, { name });
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/checklists`;
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------
|
|
|
|
// delete
|
|
|
|
// ----------------------------------
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'DELETE';
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/checklists/${id}`;
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------
|
|
|
|
// get
|
|
|
|
// ----------------------------------
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `checklists/${id}`;
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'getAll') {
|
|
|
|
// ----------------------------------
|
|
|
|
// getAll
|
|
|
|
// ----------------------------------
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/checklists`;
|
2020-01-20 05:10:19 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-23 20:20:38 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'getCheckItem') {
|
|
|
|
// ----------------------------------
|
|
|
|
// getCheckItem
|
|
|
|
// ----------------------------------
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const checkItemId = this.getNodeParameter('checkItemId', i) as string;
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/checkItem/${checkItemId}`;
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-23 20:20:38 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'createCheckItem') {
|
|
|
|
// ----------------------------------
|
|
|
|
// createCheckItem
|
|
|
|
// ----------------------------------
|
2021-02-15 00:42:41 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
2021-02-15 00:42:41 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const checklistId = this.getNodeParameter('checklistId', i) as string;
|
2021-02-15 00:42:41 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `checklists/${checklistId}/checkItems`;
|
2021-02-15 00:42:41 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const name = this.getNodeParameter('name', i) as string;
|
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, { name, ...additionalFields });
|
2021-02-15 00:42:41 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'deleteCheckItem') {
|
|
|
|
// ----------------------------------
|
|
|
|
// deleteCheckItem
|
|
|
|
// ----------------------------------
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'DELETE';
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const checkItemId = this.getNodeParameter('checkItemId', i) as string;
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/checkItem/${checkItemId}`;
|
2020-01-23 20:20:38 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'updateCheckItem') {
|
|
|
|
// ----------------------------------
|
|
|
|
// updateCheckItem
|
|
|
|
// ----------------------------------
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'PUT';
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const checkItemId = this.getNodeParameter('checkItemId', i) as string;
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/checkItem/${checkItemId}`;
|
2020-01-20 05:37:27 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-23 20:20:38 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'completedCheckItems') {
|
|
|
|
// ----------------------------------
|
|
|
|
// completedCheckItems
|
|
|
|
// ----------------------------------
|
2020-01-20 06:11:23 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2020-01-20 06:11:23 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
2020-01-20 06:11:23 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `cards/${cardId}/checkItemStates`;
|
2020-01-20 06:11:23 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-20 06:11:23 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
|
|
|
} else if (resource === 'label') {
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (operation === 'create') {
|
|
|
|
// ----------------------------------
|
|
|
|
// create
|
|
|
|
// ----------------------------------
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const idBoard = this.getNodeParameter('boardId', i) as string;
|
|
|
|
const name = this.getNodeParameter('name', i) as string;
|
|
|
|
const color = this.getNodeParameter('color', i) as string;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
Object.assign(qs, {
|
|
|
|
idBoard,
|
|
|
|
name,
|
|
|
|
color,
|
|
|
|
});
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = 'labels';
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'delete') {
|
|
|
|
// ----------------------------------
|
|
|
|
// delete
|
|
|
|
// ----------------------------------
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'DELETE';
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `labels/${id}`;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'get') {
|
|
|
|
// ----------------------------------
|
|
|
|
// get
|
|
|
|
// ----------------------------------
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `labels/${id}`;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, additionalFields);
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'getAll') {
|
|
|
|
// ----------------------------------
|
|
|
|
// getAll
|
|
|
|
// ----------------------------------
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'GET';
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const idBoard = this.getNodeParameter('boardId', i) as string;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `board/${idBoard}/labels`;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
Object.assign(qs, additionalFields);
|
|
|
|
} else if (operation === 'update') {
|
|
|
|
// ----------------------------------
|
|
|
|
// update
|
|
|
|
// ----------------------------------
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'PUT';
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `labels/${id}`;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
|
|
|
Object.assign(qs, updateFields);
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'addLabel') {
|
|
|
|
// ----------------------------------
|
|
|
|
// addLabel
|
|
|
|
// ----------------------------------
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'POST';
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
qs.value = id;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `/cards/${cardId}/idLabels`;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else if (operation === 'removeLabel') {
|
|
|
|
// ----------------------------------
|
|
|
|
// removeLabel
|
|
|
|
// ----------------------------------
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
requestMethod = 'DELETE';
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
|
|
|
const id = this.getNodeParameter('id', i) as string;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
endpoint = `/cards/${cardId}/idLabels/${id}`;
|
2020-01-20 07:28:51 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i });
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
2020-01-17 06:46:13 -08:00
|
|
|
} else {
|
2022-07-12 08:51:01 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i });
|
2020-01-17 06:46:13 -08:00
|
|
|
}
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
// resources listed here do not support pagination so
|
|
|
|
// paginate them 'manually'
|
|
|
|
const skipPagination = [
|
|
|
|
'list:getAll',
|
|
|
|
];
|
2021-01-19 06:09:03 -08:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (returnAll === true && !skipPagination.includes(`${resource}:${operation}`)) {
|
|
|
|
responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
|
|
|
|
} else {
|
|
|
|
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
|
|
|
if (returnAll === false && qs.limit) {
|
|
|
|
responseData = responseData.splice(0, qs.limit);
|
|
|
|
}
|
2021-01-19 06:09:03 -08:00
|
|
|
}
|
2019-07-12 08:54:15 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
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;
|
2020-01-17 10:20:34 -08:00
|
|
|
}
|
2019-07-12 08:54:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return [this.helpers.returnJsonArray(returnData)];
|
|
|
|
}
|
|
|
|
}
|