Add GET attachment API

This commit is contained in:
trojanh 2020-01-16 19:41:54 +05:30
parent a1972c2d61
commit 995297f87e

View file

@ -1347,11 +1347,82 @@ export class Trello implements INodeType {
value: 'list',
description: 'List all attachments',
},
{
name: 'Get',
value: 'get',
description: 'Get the data of an attachments',
},
],
default: 'list',
description: 'The operation to perform.',
},
// ----------------------------------
// attachment:create
// ----------------------------------
{
displayName: 'Card ID',
name: 'id',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'attachment',
],
},
},
description: 'The ID of the Card to get attachment.',
},
{
displayName: 'Attachment ID',
name: 'attachmentId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'attachment',
],
},
},
description: 'The ID of the attachment to get.',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'attachment',
],
},
},
default: {},
options: [
{
displayName: 'Fields',
name: 'fields',
type: 'string',
default: 'all',
description: 'Fields to return. Either "all" or a comma-separated list of fields.',
},
],
},
// ----------------------------------
// attachment:list
// ----------------------------------
@ -1371,7 +1442,7 @@ export class Trello implements INodeType {
],
},
},
description: 'The ID of the list to get.',
description: 'The ID of the Card to get attachments.',
},
{
displayName: 'Additional Fields',
@ -1400,6 +1471,72 @@ export class Trello implements INodeType {
],
},
// ----------------------------------
// attachment:get
// ----------------------------------
{
displayName: 'Card ID',
name: 'id',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'attachment',
],
},
},
description: 'The ID of the Card to get attachment.',
},
{
displayName: 'Attachment ID',
name: 'attachmentId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'attachment',
],
},
},
description: 'The ID of the attachment to get.',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'attachment',
],
},
},
default: {},
options: [
{
displayName: 'Fields',
name: 'fields',
type: 'string',
default: 'all',
description: 'Fields to return. Either "all" or a comma-separated list of fields.',
},
],
},
],
};
@ -1622,6 +1759,22 @@ export class Trello implements INodeType {
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(qs, additionalFields);
} else if (operation === 'get') {
// ----------------------------------
// get
// ----------------------------------
requestMethod = 'GET';
const id = this.getNodeParameter('id', i) as string;
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
endpoint = `cards/${id}/attachments/${attachmentId}`;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(qs, additionalFields);
} else {
throw new Error(`The operation "${operation}" is not known!`);
}