Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions components/trengo/actions/list-help-centers/list-help-centers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import utils from "../../common/utils.mjs";
import app from "../../trengo.app.mjs";

export default {
type: "action",
key: "trengo-list-help-centers",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: true,
},
name: "List Help Centers",
description: "List all help centers. [See the documentation](https://developers.trengo.com/reference/list-all-help-centers)",
props: {
app,
maxResults: {
type: "integer",
label: "Max Results",
description: "Maximum number of help centers to return (if not specified, all results will be returned)",
optional: true,
},
},
async run({ $ }) {
const helpCenters = [];
const resourcesStream = utils.getResourcesStream({
resourceFn: this.app.getHelpCenters,
resourceFnArgs: {},
});
for await (const item of resourcesStream) {
helpCenters.push(item);
if (this.maxResults && helpCenters.length >= this.maxResults) {
break;
}
}
const length = helpCenters.length;
$.export("$summary", `Successfully retrieved ${length} help center${length === 1
? ""
: "s"}`);
return helpCenters;
},
};
49 changes: 49 additions & 0 deletions components/trengo/trengo.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,55 @@ export default {
path: `/tickets/${ticketId}/labels`,
...args,
});
// Helpcenter API methods
getHelpCenter({
helpCenterId, ...args
}) {
return this._makeRequest({
path: `/help_center/${helpCenterId}`,
...args,
});
},
getCategories({
helpCenterId, ...args
}) {
return this._makeRequest({
path: `/help_center/${helpCenterId}/categories`,
...args,
});
},
getCategory({
helpCenterId, categoryId, ...args
}) {
return this._makeRequest({
path: `/help_center/${helpCenterId}/categories/${categoryId}`,
...args,
});
},
getBlocks({
helpCenterId, ...args
}) {
return this._makeRequest({
path: `/help_center/${helpCenterId}/blocks`,
...args,
});
},
getBlock({
helpCenterId, blockId, ...args
}) {
return this._makeRequest({
path: `/help_center/${helpCenterId}/blocks/${blockId}`,
...args,
});
},
getArticle({
helpCenterId, articleId, ...args
}) {
return this._makeRequest({
path: `/help_center/${helpCenterId}/articles/${articleId}`,
...args,
});
},
},
},
};