Skip to content

Commit 50d2bc7

Browse files
committed
--amend
1 parent 5799ddf commit 50d2bc7

File tree

3 files changed

+151
-2
lines changed

3 files changed

+151
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import freshdesk from "../../freshdesk.app.mjs";
22

33
export default {
4-
key: "freshdesk-set-ticket-priority-test",
4+
key: "freshdesk-set-ticket-priority",
55
name: "Set Ticket Priority",
66
description: "Update the priority of a ticket in Freshdesk",
77
version: "0.0.1",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import freshdesk from "../../freshdesk.app.mjs";
22

33
export default {
4-
key: "freshdesk-set-ticket-status-test",
4+
key: "freshdesk-set-ticket-status",
55
name: "Set Ticket Status",
66
description: "Update the status of a ticket in Freshdesk",
77
version: "0.0.1",
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
import { removeNullEntries } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "freshdesk-update-ticket-testpd",
6+
name: "Update a Ticket",
7+
description: "Update status, priority, subject, description, agent, group, tags, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
8+
version: "0.0.5",
9+
type: "action",
10+
props: {
11+
freshdesk,
12+
ticketId: {
13+
propDefinition: [
14+
freshdesk,
15+
"ticketId",
16+
],
17+
},
18+
ticketStatus: {
19+
propDefinition: [
20+
freshdesk,
21+
"ticketStatus",
22+
],
23+
optional: true,
24+
},
25+
ticketPriority: {
26+
propDefinition: [
27+
freshdesk,
28+
"ticketPriority",
29+
],
30+
optional: true,
31+
},
32+
subject: {
33+
type: "string",
34+
label: "Subject",
35+
description: "Ticket subject",
36+
optional: true,
37+
},
38+
description: {
39+
type: "string",
40+
label: "Description",
41+
description: "Detailed ticket description (HTML allowed)",
42+
optional: true,
43+
},
44+
type: {
45+
type: "string",
46+
label: "Type",
47+
description: "Type of ticket (e.g. Question, Incident, etc.)",
48+
optional: true,
49+
},
50+
group_id: {
51+
type: "integer",
52+
label: "Group ID",
53+
description: "ID of the group to assign this ticket to",
54+
optional: true,
55+
},
56+
responder_id: {
57+
type: "integer",
58+
label: "Agent ID",
59+
description: "ID of the agent to assign this ticket to",
60+
optional: true,
61+
},
62+
email: {
63+
type: "string",
64+
label: "Requester Email (replaces requester)",
65+
description: "Updates the requester. If no contact with this email exists, a new one will be created and assigned to the ticket.",
66+
optional: true,
67+
},
68+
phone: {
69+
type: "string",
70+
label: "Requester Phone (replaces requester)",
71+
description: "If no contact with this phone number exists, a new one will be created. If used without email, 'name' is required.",
72+
optional: true,
73+
},
74+
name: {
75+
type: "string",
76+
label: "Requester Name (required with phone if no email)",
77+
description: "Used when creating a contact with phone but no email.",
78+
optional: true,
79+
},
80+
type: {
81+
type: "string",
82+
label: "Type",
83+
description: "Type of ticket (must match one of the allowed values)",
84+
optional: true,
85+
options: [
86+
"Question",
87+
"Incident",
88+
"Problem",
89+
"Feature Request",
90+
"Refund",
91+
],
92+
},
93+
custom_fields: {
94+
type: "object",
95+
label: "Custom Fields",
96+
description: "Custom fields as key-value pairs (make sure types match your config)",
97+
optional: true,
98+
},
99+
},
100+
async run({ $ }) {
101+
const {
102+
freshdesk,
103+
ticketId,
104+
ticketStatus,
105+
ticketPriority,
106+
subject,
107+
description,
108+
type,
109+
group_id,
110+
responder_id,
111+
email,
112+
phone,
113+
name,
114+
tags,
115+
custom_fields,
116+
} = this;
117+
118+
const data = removeNullEntries({
119+
status: ticketStatus,
120+
priority: ticketPriority,
121+
subject,
122+
description,
123+
type,
124+
group_id,
125+
responder_id,
126+
email,
127+
phone,
128+
name,
129+
tags,
130+
custom_fields,
131+
});
132+
133+
if (!Object.keys(data).length) {
134+
throw new Error("Please provide at least one field to update.");
135+
}
136+
137+
const response = await freshdesk._makeRequest({
138+
$,
139+
method: "PUT",
140+
url: `/tickets/${ticketId}`,
141+
data,
142+
});
143+
144+
$.export("$summary", `Ticket ${ticketId} updated successfully`);
145+
return response;
146+
},
147+
};
148+
149+

0 commit comments

Comments
 (0)