-
Notifications
You must be signed in to change notification settings - Fork 5.5k
accident #16448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accident #16448
Changes from all commits
5799ddf
50d2bc7
7ed1d7a
0362927
addf466
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import freshdesk from "../../freshdesk.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "freshdesk-assign-ticket-to-agent", | ||
| name: "Assign Ticket to Agent", | ||
| description: "Assign a Freshdesk ticket to a specific agent", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| freshdesk, | ||
| ticketId: { | ||
| propDefinition: [ | ||
| freshdesk, | ||
| "ticketId", | ||
| ], | ||
| }, | ||
| responder_id: { | ||
| type: "integer", | ||
| label: "Agent ID", | ||
| description: "ID of the agent to assign this ticket to", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.freshdesk._makeRequest({ | ||
| $, | ||
| method: "PUT", | ||
| url: `/tickets/${this.ticketId}`, | ||
| data: { | ||
| responder_id: this.responder_id, | ||
| }, | ||
| }); | ||
| $.export("$summary", `Ticket ${this.ticketId} assigned to agent ${this.responder_id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import freshdesk from "../../freshdesk.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key: "freshdesk-assign-ticket-to-group", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "Assign Ticket to Group", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Assign a Freshdesk ticket to a specific group", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| freshdesk, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ticketId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| freshdesk, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "ticketId", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| group_id: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Group ID", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "ID of the group to assign this ticket to", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.freshdesk._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "PUT", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url: `/tickets/${this.ticketId}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| group_id: this.group_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling with informative messages The current implementation lacks specific error handling which could provide more context to users when things go wrong. async run({ $ }) {
+ try {
const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
group_id: this.group_id,
},
});
$.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`);
return response;
+ } catch (error) {
+ $.export("$summary", `Failed to assign ticket ${this.ticketId} to group ${this.group_id}`);
+ throw error;
+ }
},📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import freshdesk from "../../freshdesk.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "freshdesk-close-ticket", | ||
| name: "Close Ticket", | ||
| description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| freshdesk, | ||
| ticketId: { | ||
| propDefinition: [ | ||
| freshdesk, | ||
| "ticketId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const CLOSED_STATUS = 5; // Freshdesk status code for 'Closed' | ||
|
|
||
| const response = await this.freshdesk._makeRequest({ | ||
| $, | ||
| method: "PUT", | ||
| url: `/tickets/${this.ticketId}`, | ||
| data: { | ||
| status: CLOSED_STATUS, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Ticket ${this.ticketId} closed successfully`); | ||
| return response; | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Check failure on line 1 in components/freshdesk/actions/freshdesk-update-ticket/create-group-id-test.mjs
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 🔧 Replace these with your real values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const API_KEY = "YfaK2hd0KP3og3KbqV"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hardcoded API credentials The script contains what appears to be a real API key and domain. Hardcoding credentials in source code is a security risk even in test scripts. -// 🔧 Replace these with your real values
-const API_KEY = "YfaK2hd0KP3og3KbqV";
-const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
+// 🔧 Replace these with your real values
+const API_KEY = "your_api_key";
+const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const createGroup = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const res = await fetch(`https://${DOMAIN}/api/v2/groups`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "POST", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Content-Type": "application/json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: JSON.stringify({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "My Team", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const data = await res.json(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!res.ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("❌ Group create error:", data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("✅ Group created:", data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for network failures The function handles API error responses but not network errors. Add try/catch to handle potential network failures. const createGroup = async () => {
+ try {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "My Team",
}),
});
const data = await res.json();
if (!res.ok) {
console.error("❌ Group create error:", data);
return;
}
console.log("✅ Group created:", data);
+ } catch (error) {
+ console.error("❌ Network error:", error.message);
+ }
};📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createGroup(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import fetch from "node-fetch"; // if you're using Node 18+, native fetch is available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 🔧 Replace these with your real values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const API_KEY = "YfaK2hd0KP3og3KbqV"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hardcoded API credentials The script contains what appears to be a real API key and domain. Hardcoding credentials in source code is a security risk even in test scripts. -// 🔧 Replace these with your real values
-const API_KEY = "YfaK2hd0KP3og3KbqV";
-const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
+// 🔧 Replace these with your real values
+const API_KEY = "your_api_key";
+const DOMAIN = "yourdomain.freshdesk.com"; // e.g. support.freshdesk.com📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 🎟️ Ticket payload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const payload = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subject: "Test ticket for full update suite", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "<strong>This is a test ticket</strong><br>With rich HTML content.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "Question", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| priority: 2, // Medium | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: 2, // Open | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tags: ["api-test", "pipedream", "full-update"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Check failure on line 14 in components/freshdesk/actions/freshdesk-update-ticket/create-ticket.mjs
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| email: "[email protected]", // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Uncomment and customize if you have these | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| group_id: 157001089898, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| responder_id: 157005992678, //Agent ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| custom_fields: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Example: "cf_customer_type": "premium" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove potentially sensitive information from payload The ticket payload contains what appears to be real IDs, emails, and specific values. These should be replaced with placeholders in test scripts. // 🎟️ Ticket payload
const payload = {
subject: "Test ticket for full update suite",
description: "<strong>This is a test ticket</strong><br>With rich HTML content.",
type: "Question",
priority: 2, // Medium
status: 2, // Open
- tags: ["api-test", "pipedream", "full-update"],
- email: "[email protected]", //
+ tags: [
+ "api-test",
+ "pipedream",
+ "full-update"
+ ],
+ email: "[email protected]", //
// Uncomment and customize if you have these
- group_id: 157001089898,
- responder_id: 157005992678, //Agent ID
+ group_id: 123456,
+ responder_id: 123456, //Agent ID
custom_fields: {
// Example: "cf_customer_type": "premium"
},
};📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: Lint Code Base[failure] 14-14: [failure] 14-14: [failure] 14-14: [failure] 14-14: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const createTicket = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await fetch(`https://${DOMAIN}/api/v2/tickets`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "POST", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Content-Type": "application/json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: JSON.stringify(payload), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!response.ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("❌ Failed to create ticket", response.status, await response.text()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const data = await response.json(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("✅ Ticket created:", data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for network failures The function handles API error responses but not network errors. Add try/catch to handle potential network failures. const createTicket = async () => {
+ try {
const response = await fetch(`https://${DOMAIN}/api/v2/tickets`, {
method: "POST",
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (!response.ok) {
console.error("❌ Failed to create ticket", response.status, await response.text());
return;
}
const data = await response.json();
console.log("✅ Ticket created:", data);
+ } catch (error) {
+ console.error("❌ Network error:", error.message);
+ }
};📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createTicket(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,149 @@ | ||||||||||||||||||||||||||||||
| import freshdesk from "../../freshdesk.app.mjs"; | ||||||||||||||||||||||||||||||
| import { removeNullEntries } from "../../common/utils.mjs"; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||
| key: "freshdesk-update-ticket-testpd", | ||||||||||||||||||||||||||||||
| name: "Update a Ticket", | ||||||||||||||||||||||||||||||
| description: "Update status, priority, subject, description, agent, group, tags, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", | ||||||||||||||||||||||||||||||
| version: "0.0.5", | ||||||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||||||
| freshdesk, | ||||||||||||||||||||||||||||||
| ticketId: { | ||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||
| freshdesk, | ||||||||||||||||||||||||||||||
| "ticketId", | ||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| ticketStatus: { | ||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||
| freshdesk, | ||||||||||||||||||||||||||||||
| "ticketStatus", | ||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| ticketPriority: { | ||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||
| freshdesk, | ||||||||||||||||||||||||||||||
| "ticketPriority", | ||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| subject: { | ||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||
| label: "Subject", | ||||||||||||||||||||||||||||||
| description: "Ticket subject", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| description: { | ||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||
| label: "Description", | ||||||||||||||||||||||||||||||
| description: "Detailed ticket description (HTML allowed)", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| type: { | ||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||
| label: "Type", | ||||||||||||||||||||||||||||||
| description: "Type of ticket (e.g. Question, Incident, etc.)", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix duplicate 'type' property definition There's a duplicate property definition for 'type' in the props object. The first definition (lines 44-49) is being overwritten by the second definition (lines 80-92) with predefined options. Delete the first 'type' property definition: - type: {
- type: "string",
- label: "Type",
- description: "Type of ticket (e.g. Question, Incident, etc.)",
- optional: true,
- },Also applies to: 80-92 🧰 Tools🪛 Biome (1.9.4)[error] 44-49: This property value named type is later overwritten by an object member with the same name. Overwritten with this value. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored. (lint/suspicious/noDuplicateObjectKeys) |
||||||||||||||||||||||||||||||
| group_id: { | ||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||
| label: "Group ID", | ||||||||||||||||||||||||||||||
| description: "ID of the group to assign this ticket to", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| responder_id: { | ||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||
| label: "Agent ID", | ||||||||||||||||||||||||||||||
| description: "ID of the agent to assign this ticket to", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| email: { | ||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||
| label: "Requester Email (replaces requester)", | ||||||||||||||||||||||||||||||
| description: "Updates the requester. If no contact with this email exists, a new one will be created and assigned to the ticket.", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| phone: { | ||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||
| label: "Requester Phone (replaces requester)", | ||||||||||||||||||||||||||||||
| description: "If no contact with this phone number exists, a new one will be created. If used without email, 'name' is required.", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| name: { | ||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||
| label: "Requester Name (required with phone if no email)", | ||||||||||||||||||||||||||||||
| description: "Used when creating a contact with phone but no email.", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| type: { | ||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||
| label: "Type", | ||||||||||||||||||||||||||||||
| description: "Type of ticket (must match one of the allowed values)", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| options: [ | ||||||||||||||||||||||||||||||
| "Question", | ||||||||||||||||||||||||||||||
| "Incident", | ||||||||||||||||||||||||||||||
| "Problem", | ||||||||||||||||||||||||||||||
| "Feature Request", | ||||||||||||||||||||||||||||||
| "Refund", | ||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| custom_fields: { | ||||||||||||||||||||||||||||||
| type: "object", | ||||||||||||||||||||||||||||||
| label: "Custom Fields", | ||||||||||||||||||||||||||||||
| description: "Custom fields as key-value pairs (make sure types match your config)", | ||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||
| freshdesk, | ||||||||||||||||||||||||||||||
| ticketId, | ||||||||||||||||||||||||||||||
| ticketStatus, | ||||||||||||||||||||||||||||||
| ticketPriority, | ||||||||||||||||||||||||||||||
| subject, | ||||||||||||||||||||||||||||||
| description, | ||||||||||||||||||||||||||||||
| type, | ||||||||||||||||||||||||||||||
| group_id, | ||||||||||||||||||||||||||||||
| responder_id, | ||||||||||||||||||||||||||||||
| email, | ||||||||||||||||||||||||||||||
| phone, | ||||||||||||||||||||||||||||||
| name, | ||||||||||||||||||||||||||||||
| tags, | ||||||||||||||||||||||||||||||
| custom_fields, | ||||||||||||||||||||||||||||||
|
Comment on lines
+114
to
+115
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add missing 'tags' property definition The 'tags' property is used in the run method and included in the data object, but it's not defined in the props object. Add the tags property definition: custom_fields: {
type: "object",
label: "Custom Fields",
description: "Custom fields as key-value pairs (make sure types match your config)",
optional: true,
},
+ tags: {
+ type: "string[]",
+ label: "Tags",
+ description: "Tags to be associated with the ticket",
+ optional: true,
+ },📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
| } = this; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const data = removeNullEntries({ | ||||||||||||||||||||||||||||||
| status: ticketStatus, | ||||||||||||||||||||||||||||||
| priority: ticketPriority, | ||||||||||||||||||||||||||||||
| subject, | ||||||||||||||||||||||||||||||
| description, | ||||||||||||||||||||||||||||||
| type, | ||||||||||||||||||||||||||||||
| group_id, | ||||||||||||||||||||||||||||||
| responder_id, | ||||||||||||||||||||||||||||||
| email, | ||||||||||||||||||||||||||||||
| phone, | ||||||||||||||||||||||||||||||
| name, | ||||||||||||||||||||||||||||||
| tags, | ||||||||||||||||||||||||||||||
| custom_fields, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (!Object.keys(data).length) { | ||||||||||||||||||||||||||||||
| throw new Error("Please provide at least one field to update."); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const response = await freshdesk._makeRequest({ | ||||||||||||||||||||||||||||||
| $, | ||||||||||||||||||||||||||||||
| method: "PUT", | ||||||||||||||||||||||||||||||
| url: `/tickets/${ticketId}`, | ||||||||||||||||||||||||||||||
| data, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| $.export("$summary", `Ticket ${ticketId} updated successfully`); | ||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+147
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate component with testing suffix This component appears to be a duplicate of Choose one location for this component and remove the duplicate. Based on the version numbers, the other file (0.0.6) seems to be the production version, suggesting this one (-testpd, 0.0.5) should be removed. 🧰 Tools🪛 Biome (1.9.4)[error] 44-49: This property value named type is later overwritten by an object member with the same name. Overwritten with this value. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored. (lint/suspicious/noDuplicateObjectKeys) |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 🔧 Replace with your values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const API_KEY = "your_api_key"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const DOMAIN = "yourdomain.freshdesk.com"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const getGroups = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const res = await fetch(`https://${DOMAIN}/api/v2/groups`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Content-Type": "application/json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const data = await res.json(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!res.ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("❌ Failed to fetch groups:", data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("✅ Group List:"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data.forEach(group => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`- ${group.name}: ${group.id}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for network failures The function handles API error responses but not network errors. Add try/catch to handle potential network failures. const getGroups = async () => {
+ try {
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
headers: {
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
"Content-Type": "application/json",
},
});
const data = await res.json();
if (!res.ok) {
console.error("❌ Failed to fetch groups:", data);
return;
}
console.log("✅ Group List:");
data.forEach(group => {
console.log(`- ${group.name}: ${group.id}`);
});
+ } catch (error) {
+ console.error("❌ Network error:", error.message);
+ }
};📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getGroups(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,36 @@ | ||||||||
| import freshdesk from "../../freshdesk.app.mjs"; | ||||||||
|
|
||||||||
| export default { | ||||||||
| key: "freshdesk-set-ticket-priority", | ||||||||
| name: "Set Ticket Priority", | ||||||||
| description: "Update the priority of a ticket in Freshdesk", | ||||||||
| version: "0.0.1", | ||||||||
| type: "action", | ||||||||
| props: { | ||||||||
| freshdesk, | ||||||||
| ticketId: { | ||||||||
| propDefinition: [ | ||||||||
| freshdesk, | ||||||||
| "ticketId", | ||||||||
| ], | ||||||||
| }, | ||||||||
| ticketPriority: { | ||||||||
| propDefinition: [ | ||||||||
| freshdesk, | ||||||||
| "ticketPriority", | ||||||||
| ], | ||||||||
| }, | ||||||||
| }, | ||||||||
| async run({ $ }) { | ||||||||
| const response = await this.freshdesk._makeRequest({ | ||||||||
| $, | ||||||||
| method: "PUT", | ||||||||
| url: `/tickets/${this.ticketId}`, | ||||||||
| data: { | ||||||||
| priority: this.ticketPriority, | ||||||||
| }, | ||||||||
| }); | ||||||||
| $.export("$summary", `Ticket ${this.ticketId} priority updated to ${this.ticketPriority}`); | ||||||||
| return response; | ||||||||
| }, | ||||||||
| }; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainCheck for missing newline at end of file Since there was a linting error in the assign-ticket-to-agent file about a missing newline, check if this file also needs one at the end. 🏁 Script executed: #!/bin/bash
# Check if file ends with a newline
if [ "$(tail -c1 components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs | wc -l)" -eq 0 ]; then
echo "File is missing a newline at the end"
else
echo "File has a newline at the end"
fiLength of output: 194 Add missing newline at end of file The file • File needing update: • Suggested change (add an empty line at EOF): }; // existing last line of code
+ ← add a single newline here📝 Committable suggestion
Suggested change
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good implementation, but missing newline at end of file
The implementation of this action looks good and follows the same pattern as the other Freshdesk actions. It correctly assigns a ticket to an agent by updating the responder_id field.
Fix the linting error by adding a newline at the end of the file:
}, }; +📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: Lint Code Base
[failure] 35-35:
Newline required at end of file but not found
🪛 GitHub Actions: Pull Request Checks
[error] 35-35: ESLint: Newline required at end of file but not found (eol-last)