mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
⚡ Some improvements to Trello attachments
This commit is contained in:
parent
fb36c6e136
commit
0d7379ab70
|
@ -39,6 +39,10 @@ export class Trello implements INodeType {
|
||||||
name: 'resource',
|
name: 'resource',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
name: "Attachment",
|
||||||
|
value: "attachment"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Board',
|
name: 'Board',
|
||||||
value: 'board',
|
value: 'board',
|
||||||
|
@ -51,10 +55,6 @@ export class Trello implements INodeType {
|
||||||
name: 'List',
|
name: 'List',
|
||||||
value: 'list',
|
value: 'list',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Attachment",
|
|
||||||
value: "attachment"
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
default: 'card',
|
default: 'card',
|
||||||
description: 'The resource to operate on.',
|
description: 'The resource to operate on.',
|
||||||
|
@ -1248,12 +1248,12 @@ export class Trello implements INodeType {
|
||||||
description: 'Get the data of an attachments',
|
description: 'Get the data of an attachments',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'List',
|
name: 'Get All',
|
||||||
value: 'list',
|
value: 'getAll',
|
||||||
description: 'List all attachments for the card',
|
description: 'Returns all attachments for the card',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
default: 'list',
|
default: 'getAll',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1276,10 +1276,10 @@ export class Trello implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The ID of the Card to get attachment.',
|
description: 'The ID of the card to add attachment to.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Attachment URL',
|
displayName: 'Source URL',
|
||||||
name: 'url',
|
name: 'url',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -1294,13 +1294,13 @@ export class Trello implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The ID of the attachment to get.',
|
description: 'The URL of the attachment to add.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Attachment Name',
|
displayName: 'Additional Fields',
|
||||||
name: 'name',
|
name: 'additionalFields',
|
||||||
type: 'string',
|
type: 'collection',
|
||||||
default: '',
|
placeholder: 'Add Field',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
|
@ -1311,24 +1311,24 @@ export class Trello implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The ID of the attachment to get.',
|
default: {},
|
||||||
},
|
options: [
|
||||||
{
|
{
|
||||||
displayName: 'Attachment mimeType',
|
displayName: 'MIME Type',
|
||||||
name: 'mimeType',
|
name: 'mimeType',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
displayOptions: {
|
placeholder: 'image/png',
|
||||||
show: {
|
description: 'The MIME type of the attachment to add.',
|
||||||
operation: [
|
|
||||||
'create',
|
|
||||||
],
|
|
||||||
resource: [
|
|
||||||
'attachment',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
description: 'The ID of the attachment to get.',
|
displayName: 'Name',
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'The name of the attachment to add.',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
@ -1350,7 +1350,7 @@ export class Trello implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The ID of the Card to get attachments.',
|
description: 'The ID of the card to get delete.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Attachment ID',
|
displayName: 'Attachment ID',
|
||||||
|
@ -1368,11 +1368,11 @@ export class Trello implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The ID of the attachment to get.',
|
description: 'The ID of the attachment to delete.',
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// attachment:list
|
// attachment:getAll
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
{
|
{
|
||||||
displayName: 'Card ID',
|
displayName: 'Card ID',
|
||||||
|
@ -1383,14 +1383,14 @@ export class Trello implements INodeType {
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
'list',
|
'getAll',
|
||||||
],
|
],
|
||||||
resource: [
|
resource: [
|
||||||
'attachment',
|
'attachment',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The ID of the Card to get attachments.',
|
description: 'The ID of the card to get attachments.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Additional Fields',
|
displayName: 'Additional Fields',
|
||||||
|
@ -1400,7 +1400,7 @@ export class Trello implements INodeType {
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
'list',
|
'getAll',
|
||||||
],
|
],
|
||||||
resource: [
|
resource: [
|
||||||
'attachment',
|
'attachment',
|
||||||
|
@ -1438,7 +1438,7 @@ export class Trello implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'The ID of the Card to get attachment.',
|
description: 'The ID of the card to get attachment.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Attachment ID',
|
displayName: 'Attachment ID',
|
||||||
|
@ -1698,25 +1698,26 @@ export class Trello implements INodeType {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// create
|
// create
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'POST';
|
requestMethod = 'POST';
|
||||||
|
|
||||||
const cardId = this.getNodeParameter('cardId', i) as string;
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
||||||
const name = this.getNodeParameter('name', i) as string;
|
|
||||||
const url = this.getNodeParameter('url', i) as string;
|
const url = this.getNodeParameter('url', i) as string;
|
||||||
const mimeType = this.getNodeParameter('mimeType', i) as string;
|
|
||||||
|
|
||||||
endpoint = `cards/${cardId}/attachments`;
|
|
||||||
|
|
||||||
Object.assign(qs, {
|
Object.assign(qs, {
|
||||||
name,
|
url,
|
||||||
mimeType,
|
|
||||||
url
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
Object.assign(qs, additionalFields);
|
||||||
|
|
||||||
|
endpoint = `cards/${cardId}/attachments`;
|
||||||
|
|
||||||
} else if (operation === 'delete') {
|
} else if (operation === 'delete') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// delete
|
// delete
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'DELETE';
|
requestMethod = 'DELETE';
|
||||||
|
|
||||||
const cardId = this.getNodeParameter('cardId', i) as string;
|
const cardId = this.getNodeParameter('cardId', i) as string;
|
||||||
|
@ -1739,9 +1740,9 @@ export class Trello implements INodeType {
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
Object.assign(qs, additionalFields);
|
Object.assign(qs, additionalFields);
|
||||||
|
|
||||||
} else if (operation === 'list') {
|
} else if (operation === 'getAll') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// list
|
// getAll
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
requestMethod = 'GET';
|
requestMethod = 'GET';
|
||||||
|
@ -1761,7 +1762,11 @@ export class Trello implements INodeType {
|
||||||
|
|
||||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||||
|
|
||||||
returnData.push(responseData as IDataObject);
|
if (Array.isArray(responseData)) {
|
||||||
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||||
|
} else {
|
||||||
|
returnData.push(responseData as IDataObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [this.helpers.returnJsonArray(returnData)];
|
return [this.helpers.returnJsonArray(returnData)];
|
||||||
|
|
Loading…
Reference in a new issue