Skip to content

Commit d990148

Browse files
committed
[ACTION] trengo - Helpcenter
1 parent 10ad254 commit d990148

File tree

9 files changed

+352
-1
lines changed

9 files changed

+352
-1
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: 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-list-all-blocks",
5+
name: "List All Blocks",
6+
description: "List all blocks in a help center. [See the documentation](https://developers.trengo.com/reference/list-all-blocks)",
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.listBlocks({
25+
$,
26+
helpCenterId: this.helpCenterId,
27+
});
28+
$.export("$summary", "Successfully listed blocks");
29+
return response;
30+
},
31+
};
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-list-all-categories",
5+
name: "List All Categories",
6+
description: "List all categories in a help center. [See the documentation](https://developers.trengo.com/reference/list-all-categories)",
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.listCategories({
25+
$,
26+
helpCenterId: this.helpCenterId,
27+
});
28+
$.export("$summary", "Successfully listed categories");
29+
return response;
30+
},
31+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from "../../trengo.app.mjs";
2+
3+
export default {
4+
key: "trengo-list-all-help-centers",
5+
name: "List All Help Centers",
6+
description: "List all help centers. [See the documentation](https://developers.trengo.com/reference/list-all-help-centers)",
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+
},
17+
async run({ $ }) {
18+
const response = await this.app.getHelpCenters({
19+
$,
20+
});
21+
$.export("$summary", "Successfully listed help centers");
22+
return response;
23+
},
24+
};

components/trengo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/trengo",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"description": "Pipedream Trengo Components",
55
"main": "trengo.app.mjs",
66
"keywords": [

components/trengo/trengo.app.mjs

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,63 @@ export default {
208208
}));
209209
},
210210
},
211+
categoryId: {
212+
type: "integer",
213+
label: "Category ID",
214+
description: "Select a category or provide an ID",
215+
async options({
216+
helpCenterId, page = 0,
217+
}) {
218+
const response = await this.listCategories({
219+
helpCenterId,
220+
params: {
221+
page: page + 1,
222+
},
223+
});
224+
return response.data.map((category) => ({
225+
label: category.name,
226+
value: category.id,
227+
}));
228+
},
229+
},
230+
articleId: {
231+
type: "integer",
232+
label: "Article ID",
233+
description: "Select an article or provide an ID",
234+
async options({
235+
helpCenterId, page = 0,
236+
}) {
237+
const response = await this.getArticles({
238+
helpCenterId,
239+
params: {
240+
page: page + 1,
241+
},
242+
});
243+
return response.data.map((article) => ({
244+
label: article.title,
245+
value: article.id,
246+
}));
247+
},
248+
},
249+
blockId: {
250+
type: "integer",
251+
label: "Block ID",
252+
description: "Select a block or provide an ID",
253+
async options({
254+
helpCenterId, page = 0,
255+
}) {
256+
const response = await this.listBlocks({
257+
helpCenterId,
258+
params: {
259+
page: page + 1,
260+
},
261+
});
262+
return response.data.map((block) => ({
263+
label: block.name,
264+
value: block.id,
265+
}));
266+
},
267+
},
211268
},
212269
methods: {
213270
_getUrl(path) {
@@ -371,5 +428,59 @@ export default {
371428
...args,
372429
});
373430
},
431+
listQuickReplies(args = {}) {
432+
return this._makeRequest({
433+
path: "/quick_replies",
434+
...args,
435+
});
436+
},
437+
getHelpCenter({
438+
helpCenterId, ...args
439+
} = {}) {
440+
return this._makeRequest({
441+
path: `/help_center/${helpCenterId}`,
442+
...args,
443+
});
444+
},
445+
listCategories({
446+
helpCenterId, ...args
447+
} = {}) {
448+
return this._makeRequest({
449+
path: `/help_center/${helpCenterId}/categories`,
450+
...args,
451+
});
452+
},
453+
getCategory({
454+
helpCenterId, categoryId, ...args
455+
} = {}) {
456+
return this._makeRequest({
457+
path: `/help_center/${helpCenterId}/categories/${categoryId}`,
458+
...args,
459+
});
460+
},
461+
getArticle({
462+
helpCenterId, articleId, ...args
463+
} = {}) {
464+
return this._makeRequest({
465+
path: `/help_center/${helpCenterId}/articles/${articleId}`,
466+
...args,
467+
});
468+
},
469+
listBlocks({
470+
helpCenterId, ...args
471+
} = {}) {
472+
return this._makeRequest({
473+
path: `/help_center/${helpCenterId}/blocks`,
474+
...args,
475+
});
476+
},
477+
getBlock({
478+
helpCenterId, blockId, ...args
479+
} = {}) {
480+
return this._makeRequest({
481+
path: `/help_center/${helpCenterId}/blocks/${blockId}`,
482+
...args,
483+
});
484+
},
374485
},
375486
};

0 commit comments

Comments
 (0)