Skip to content

Commit 288c227

Browse files
initial action get comments
1 parent afa8fb1 commit 288c227

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import app from "../../box.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
name: "Get Comments",
6+
description: "Fetches comments for a file. [See the documentation](https://developer.box.com/reference/get-files-id-comments/).",
7+
key: "box-get-comments",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
fileId: {
13+
type: "integer",
14+
label: "File ID",
15+
description: "The file ID to get comments from. Use a custom expression to reference a file from your workflow",
16+
},
17+
},
18+
async run({ $ }) {
19+
const results = [];
20+
const resourcesStream = utils.getResourcesStream({
21+
resourceFn: this.app.getComments,
22+
resourceFnArgs: {
23+
$,
24+
fileId: this.fileId,
25+
},
26+
});
27+
for await (const resource of resourcesStream) {
28+
results.push(resource);
29+
}
30+
// eslint-disable-next-line multiline-ternary
31+
$.export("$summary", results.length ? `Successfully fetched ${results.length} comment${results.length === 1 ? "" : "s"}.` : "No comments found.");
32+
return results;
33+
},
34+
};

components/box/box.app.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,5 +310,14 @@ export default {
310310
...args,
311311
});
312312
},
313+
async getComments({
314+
fileId, ...args
315+
} = {}) {
316+
return this._makeRequest({
317+
method: "GET",
318+
path: `/files/${fileId}/comments`,
319+
...args,
320+
});
321+
},
313322
},
314323
};

0 commit comments

Comments
 (0)