Skip to content

Commit 0f6c108

Browse files
committed
[ACTION] trengo - Helpcenter
1 parent 01875e4 commit 0f6c108

File tree

8 files changed

+407
-0
lines changed

8 files changed

+407
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import app from "../../trengo.app.mjs";
2+
3+
export default {
4+
key: "trengo-get-article",
5+
name: "Get Article",
6+
description: "Get a specific article. [See the documentation](https://developers.trengo.com/reference/get-an-article)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
helpCenterId: {
17+
propDefinition: [
18+
app,
19+
"helpCenterId",
20+
],
21+
},
22+
articleId: {
23+
propDefinition: [
24+
app,
25+
"articleId",
26+
({ helpCenterId }) => ({
27+
helpCenterId,
28+
}),
29+
],
30+
},
31+
},
32+
async run({ $ }) {
33+
const response = await this.app.getArticle({
34+
$,
35+
helpCenterId: this.helpCenterId,
36+
articleId: this.articleId,
37+
});
38+
$.export("$summary", "Successfully retrieved article");
39+
return response;
40+
},
41+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import app from "../../trengo.app.mjs";
2+
3+
export default {
4+
key: "trengo-get-block",
5+
name: "Get Block",
6+
description: "Get a specific block. [See the documentation](https://developers.trengo.com/reference/get-a-block)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
helpCenterId: {
17+
propDefinition: [
18+
app,
19+
"helpCenterId",
20+
],
21+
},
22+
blockId: {
23+
propDefinition: [
24+
app,
25+
"blockId",
26+
({ helpCenterId }) => ({
27+
helpCenterId,
28+
}),
29+
],
30+
},
31+
},
32+
async run({ $ }) {
33+
const response = await this.app.getBlock({
34+
$,
35+
helpCenterId: this.helpCenterId,
36+
blockId: this.blockId,
37+
});
38+
$.export("$summary", "Successfully retrieved block");
39+
return response;
40+
},
41+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import app from "../../trengo.app.mjs";
2+
3+
export default {
4+
key: "trengo-get-category",
5+
name: "Get Category",
6+
description: "Get a specific category. [See the documentation](https://developers.trengo.com/reference/get-a-category)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
helpCenterId: {
17+
propDefinition: [
18+
app,
19+
"helpCenterId",
20+
],
21+
},
22+
categoryId: {
23+
propDefinition: [
24+
app,
25+
"categoryId",
26+
({ helpCenterId }) => ({
27+
helpCenterId,
28+
}),
29+
],
30+
},
31+
},
32+
async run({ $ }) {
33+
const response = await this.app.getCategory({
34+
$,
35+
helpCenterId: this.helpCenterId,
36+
categoryId: this.categoryId,
37+
});
38+
$.export("$summary", "Successfully retrieved category");
39+
return response;
40+
},
41+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../trengo.app.mjs";
2+
3+
export default {
4+
key: "trengo-get-help-center",
5+
name: "Get Help Center",
6+
description: "Get a specific help center. [See the documentation](https://developers.trengo.com/reference/get-a-help-center)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
app,
16+
helpCenterId: {
17+
propDefinition: [
18+
app,
19+
"helpCenterId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.app.getHelpCenter({
25+
$,
26+
helpCenterId: this.helpCenterId,
27+
});
28+
$.export("$summary", "Successfully retrieved help center");
29+
return response;
30+
},
31+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import utils from "../../common/utils.mjs";
2+
import app from "../../trengo.app.mjs";
3+
4+
export default {
5+
key: "trengo-list-all-blocks",
6+
name: "List All Blocks",
7+
description: "List all blocks in a help center. [See the documentation](https://developers.trengo.com/reference/list-all-blocks)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
props: {
16+
app,
17+
helpCenterId: {
18+
propDefinition: [
19+
app,
20+
"helpCenterId",
21+
],
22+
},
23+
maxResults: {
24+
type: "integer",
25+
label: "Max Results",
26+
description: "Maximum number of blocks to return (if not specified, all results will be returned)",
27+
optional: true,
28+
},
29+
},
30+
async run({ $ }) {
31+
const blocks = [];
32+
const resourcesStream = utils.getResourcesStream({
33+
resourceFn: this.app.listBlocks,
34+
resourceFnArgs: {
35+
helpCenterId: this.helpCenterId,
36+
},
37+
});
38+
for await (const item of resourcesStream) {
39+
blocks.push(item);
40+
if (this.maxResults && blocks.length >= this.maxResults) {
41+
break;
42+
}
43+
}
44+
const length = blocks.length;
45+
$.export("$summary", `Successfully retrieved ${length} block${length === 1
46+
? ""
47+
: "s"}`);
48+
return blocks;
49+
},
50+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import utils from "../../common/utils.mjs";
2+
import app from "../../trengo.app.mjs";
3+
4+
export default {
5+
key: "trengo-list-all-categories",
6+
name: "List All Categories",
7+
description: "List all categories in a help center. [See the documentation](https://developers.trengo.com/reference/list-all-categories)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
props: {
16+
app,
17+
helpCenterId: {
18+
propDefinition: [
19+
app,
20+
"helpCenterId",
21+
],
22+
},
23+
maxResults: {
24+
type: "integer",
25+
label: "Max Results",
26+
description: "Maximum number of categories to return (if not specified, all results will be returned)",
27+
optional: true,
28+
},
29+
},
30+
async run({ $ }) {
31+
const categories = [];
32+
const resourcesStream = utils.getResourcesStream({
33+
resourceFn: this.app.listCategories,
34+
resourceFnArgs: {
35+
helpCenterId: this.helpCenterId,
36+
},
37+
});
38+
for await (const item of resourcesStream) {
39+
categories.push(item);
40+
if (this.maxResults && categories.length >= this.maxResults) {
41+
break;
42+
}
43+
}
44+
const length = categories.length;
45+
$.export("$summary", `Successfully retrieved ${length} categor${length === 1
46+
? "y"
47+
: "ies"}`);
48+
return categories;
49+
},
50+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import utils from "../../common/utils.mjs";
2+
import app from "../../trengo.app.mjs";
3+
4+
export default {
5+
type: "action",
6+
key: "trengo-list-help-centers",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
name: "List Help Centers",
14+
description: "List all help centers. [See the documentation](https://developers.trengo.com/reference/list-all-help-centers)",
15+
props: {
16+
app,
17+
maxResults: {
18+
type: "integer",
19+
label: "Max Results",
20+
description: "Maximum number of help centers to return (if not specified, all results will be returned)",
21+
optional: true,
22+
},
23+
},
24+
async run({ $ }) {
25+
const helpCenters = [];
26+
const resourcesStream = utils.getResourcesStream({
27+
resourceFn: this.app.getHelpCenters,
28+
resourceFnArgs: {},
29+
});
30+
for await (const item of resourcesStream) {
31+
helpCenters.push(item);
32+
if (this.maxResults && helpCenters.length >= this.maxResults) {
33+
break;
34+
}
35+
}
36+
const length = helpCenters.length;
37+
$.export("$summary", `Successfully retrieved ${length} help center${length === 1
38+
? ""
39+
: "s"}`);
40+
return helpCenters;
41+
},
42+
};

0 commit comments

Comments
 (0)