|
1 | | -import type { IExecuteFunctions } from 'n8n-workflow'; |
| 1 | +import type { IExecuteFunctions, INodeProperties } from 'n8n-workflow'; |
2 | 2 | import { |
3 | 3 | createParameterWithDisplayOptions, |
4 | 4 | postUrlParameter, |
5 | 5 | commentTextParameter, |
| 6 | + postCompanyUrlParameter, |
6 | 7 | } from '../../shared/SharedParameters'; |
7 | 8 | import { StandardLinkedApiOperation } from '../../shared/LinkedApiOperation'; |
8 | 9 | import { AVAILABLE_ACTION } from '../../shared/AvailableActions'; |
9 | 10 |
|
10 | 11 | export class CommentOnPost extends StandardLinkedApiOperation { |
11 | 12 | operationName = AVAILABLE_ACTION.commentOnPost; |
12 | 13 |
|
13 | | - fields = [ |
| 14 | + fields: INodeProperties[] = [ |
14 | 15 | createParameterWithDisplayOptions(postUrlParameter, this.show), |
15 | 16 | createParameterWithDisplayOptions(commentTextParameter, this.show), |
| 17 | + { |
| 18 | + displayName: 'Additional Parameters', |
| 19 | + name: 'additionalParameters', |
| 20 | + type: 'collection', |
| 21 | + placeholder: 'Add Field', |
| 22 | + default: {}, |
| 23 | + displayOptions: { |
| 24 | + show: this.show, |
| 25 | + }, |
| 26 | + options: [postCompanyUrlParameter], |
| 27 | + }, |
16 | 28 | ]; |
17 | 29 |
|
18 | 30 | public body(context: IExecuteFunctions): Record<string, any> { |
19 | | - return { |
| 31 | + const additionalParameters = context.getNodeParameter('additionalParameters', 0, {}) as { |
| 32 | + postCompanyUrl?: string; |
| 33 | + }; |
| 34 | + |
| 35 | + const body: Record<string, any> = { |
20 | 36 | postUrl: this.stringParameter(context, 'postUrl'), |
21 | 37 | text: this.stringParameter(context, 'commentText'), |
22 | 38 | }; |
| 39 | + |
| 40 | + if (additionalParameters.postCompanyUrl) { |
| 41 | + body.companyUrl = additionalParameters.postCompanyUrl; |
| 42 | + } |
| 43 | + |
| 44 | + return body; |
23 | 45 | } |
24 | 46 | } |
0 commit comments