Skip to content

Commit 5123954

Browse files
committed
[ACTION] trengo - close ticket
1 parent 10ad254 commit 5123954

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import app from "../../trengo.app.mjs";
2+
3+
export default {
4+
key: "trengo-close-ticket",
5+
name: "Close Ticket",
6+
description: "Close a ticket. [See the documentation](https://developers.trengo.com/reference/close-a-ticket)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: true,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
app,
16+
ticketId: {
17+
propDefinition: [
18+
app,
19+
"ticketId",
20+
],
21+
},
22+
ticketResultId: {
23+
propDefinition: [
24+
app,
25+
"ticketResultId",
26+
],
27+
},
28+
},
29+
async run({ $ }) {
30+
const response = await this.app.closeTicket({
31+
$,
32+
ticketId: this.ticketId,
33+
data: {
34+
ticket_result_id: this.ticketResultId,
35+
},
36+
});
37+
38+
$.export("$summary", "Successfully closed ticket");
39+
40+
return response;
41+
},
42+
};

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,23 @@ export default {
208208
}));
209209
},
210210
},
211+
ticketResultId: {
212+
type: "integer",
213+
label: "Ticket Result ID",
214+
description: "Select a ticket result or provide an ID",
215+
optional: true,
216+
async options({ page = 0 }) {
217+
const response = await this.listTicketResults({
218+
params: {
219+
page: page + 1,
220+
},
221+
});
222+
return response.data.map((ticketResult) => ({
223+
label: ticketResult.name,
224+
value: ticketResult.id,
225+
}));
226+
},
227+
},
211228
},
212229
methods: {
213230
_getUrl(path) {
@@ -371,5 +388,20 @@ export default {
371388
...args,
372389
});
373390
},
391+
closeTicket({
392+
ticketId, ...args
393+
}) {
394+
return this._makeRequest({
395+
method: "POST",
396+
path: `/tickets/${ticketId}/close`,
397+
...args,
398+
});
399+
},
400+
listTicketResults(args = {}) {
401+
return this._makeRequest({
402+
path: "/ticket_results",
403+
...args,
404+
});
405+
},
374406
},
375407
};

0 commit comments

Comments
 (0)