Skip to content

Commit f532bd3

Browse files
committed
get-comment, add-comment
1 parent 0d5fd08 commit f532bd3

File tree

4 files changed

+137
-2
lines changed

4 files changed

+137
-2
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-add-comment",
5+
name: "Add Comment",
6+
description: "Add a comment to a conversation. [See the documentation](https://dev.frontapp.com/reference/add-comment)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
conversationId: {
12+
propDefinition: [
13+
frontApp,
14+
"conversationId",
15+
],
16+
},
17+
body: {
18+
type: "string",
19+
label: "Body",
20+
description: "Content of the comment. Can include markdown formatting.",
21+
},
22+
authorId: {
23+
propDefinition: [
24+
frontApp,
25+
"teammateId",
26+
],
27+
label: "Author ID",
28+
optional: true,
29+
},
30+
isPinned: {
31+
type: "boolean",
32+
label: "Is Pinned?",
33+
description: "Whether or not the comment is pinned in its conversation",
34+
optional: true,
35+
},
36+
},
37+
async run({ $ }) {
38+
const response = await this.frontApp.addComment({
39+
$,
40+
conversationId: this.conversationId,
41+
data: {
42+
body: this.body,
43+
author_id: this.authorId,
44+
is_pinned: this.isPinned,
45+
},
46+
});
47+
$.export("$summary", `Successfully created comment with ID: ${response.id}`);
48+
return response;
49+
},
50+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-get-comment",
5+
name: "Get Comment",
6+
description: "Retrieve a comment from a conversation. [See the documentation](https://dev.frontapp.com/reference/get-comment)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
conversationId: {
12+
propDefinition: [
13+
frontApp,
14+
"conversationId",
15+
],
16+
},
17+
commentId: {
18+
propDefinition: [
19+
frontApp,
20+
"commentId",
21+
(c) => ({
22+
conversationId: c.conversationId,
23+
}),
24+
],
25+
},
26+
},
27+
async run({ $ }) {
28+
const response = await this.frontApp.getComment({
29+
$,
30+
commentId: this.commentId,
31+
});
32+
$.export("$summary", `Successfully retrieved comment with ID: ${this.commentId}`);
33+
return response;
34+
},
35+
};

components/frontapp/frontapp.app.mjs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,28 @@ export default {
165165
});
166166
},
167167
},
168+
commentId: {
169+
type: "string",
170+
label: "Comment ID",
171+
description: "ID of the comment to retrieve",
172+
async options({
173+
prevContext, conversationId,
174+
}) {
175+
return this.paginateOptions({
176+
prevContext,
177+
listResourcesFn: this.listComments,
178+
mapper: ({
179+
id, body,
180+
}) => ({
181+
label: body.slice(0, 50),
182+
value: id,
183+
}),
184+
args: {
185+
conversationId,
186+
},
187+
});
188+
},
189+
},
168190
to: {
169191
type: "string[]",
170192
label: "To",
@@ -329,12 +351,38 @@ export default {
329351
...args,
330352
});
331353
},
354+
getComment({
355+
commentId, ...args
356+
}) {
357+
return this.makeRequest({
358+
path: `/comments/${commentId}`,
359+
...args,
360+
});
361+
},
362+
listComments({
363+
conversationId, ...args
364+
}) {
365+
return this.makeRequest({
366+
path: `/conversations/${conversationId}/comments`,
367+
...args,
368+
});
369+
},
370+
addComment({
371+
conversationId, ...args
372+
}) {
373+
return this.makeRequest({
374+
method: "POST",
375+
path: `/conversations/${conversationId}/comments`,
376+
...args,
377+
});
378+
},
332379
async paginateOptions({
333380
prevContext,
334381
listResourcesFn,
335382
filter = () => true,
336383
mapper = (resource) => resource,
337384
appendNull = false,
385+
args = {},
338386
} = {}) {
339387
const { pageToken } = prevContext;
340388

@@ -353,7 +401,9 @@ export default {
353401
_pagination: { next: nextPageToken },
354402
_results: resources,
355403
} = await listResourcesFn({
404+
...args,
356405
params: {
406+
...args?.params,
357407
page_token: pageToken,
358408
},
359409
});

components/frontapp/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/frontapp",
3-
"version": "0.5.1",
3+
"version": "0.6.0",
44
"description": "Pipedream Frontapp Components",
55
"main": "frontapp.app.mjs",
66
"keywords": [
@@ -10,7 +10,7 @@
1010
"homepage": "https://pipedream.com/apps/frontapp",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13-
"@pipedream/platform": "^0.10.0",
13+
"@pipedream/platform": "^3.0.3",
1414
"form-data": "^4.0.0"
1515
},
1616
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",

0 commit comments

Comments
 (0)