Skip to content

Commit f62a55f

Browse files
authored
Freshdesk fixes and improvements (#16051)
* pnpm * Fixes and improvements across app and all actions * Version bumps * pnpm * Version bumps * Adjusting request format for sources
1 parent 0b97c02 commit f62a55f

File tree

11 files changed

+233
-220
lines changed

11 files changed

+233
-220
lines changed
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
1-
import { removeNullEntries } from "../../common/utils.mjs";
21
import freshdesk from "../../freshdesk.app.mjs";
32

43
export default {
54
key: "freshdesk-create-company",
65
name: "Create a Company",
7-
description: "Create a company. [See docs here](https://developers.freshdesk.com/api/#companies)",
8-
version: "0.0.1",
6+
description: "Create a company. [See the documentation](https://developers.freshdesk.com/api/#create_company)",
7+
version: "0.0.2",
98
type: "action",
109
props: {
1110
freshdesk,
1211
name: {
1312
type: "string",
1413
label: "Name",
15-
description: "Name of the company.",
14+
description: "Name of the company",
1615
},
1716
description: {
1817
type: "string",
1918
label: "Description",
20-
description: "Description of the company.",
19+
description: "Description of the company",
2120
optional: true,
2221
},
2322
note: {
2423
type: "string",
2524
label: "Note",
26-
description: "Any specific note about the company.",
25+
description: "Any specific note about the company",
2726
optional: true,
2827
},
2928
industry: {
3029
type: "string",
3130
label: "Industry",
32-
description: "The industry the company serves in.",
31+
description: "The industry the company serves in",
3332
optional: true,
3433
},
3534
domains: {
@@ -40,18 +39,14 @@ export default {
4039
},
4140
},
4241
async run({ $ }) {
43-
const payload = removeNullEntries({
44-
name: this.name,
45-
domains: this.domains,
46-
note: this.note,
47-
industry: this.industry,
48-
description: this.description,
49-
});
50-
const response = await this.freshdesk.createCompany({
42+
const {
43+
freshdesk, ...data
44+
} = this;
45+
const response = await freshdesk.createCompany({
5146
$,
52-
payload,
47+
data,
5348
});
54-
response && $.export("$summary", "Company sucessfully created");
49+
response && $.export("$summary", "Company successfully created");
5550
return response;
5651
},
5752
};

components/freshdesk/actions/create-contact/create-contact.mjs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { removeNullEntries } from "../../common/utils.mjs";
21
import freshdesk from "../../freshdesk.app.mjs";
32

43
export default {
54
key: "freshdesk-create-contact",
65
name: "Create a Contact",
7-
description: "Create a contact. [See docs here](https://developers.freshdesk.com/api/#create_contact)",
8-
version: "0.0.1",
6+
description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)",
7+
version: "0.0.2",
98
type: "action",
109
props: {
1110
freshdesk,
@@ -16,20 +15,20 @@ export default {
1615
},
1716
email: {
1817
type: "string",
19-
label: "Email",
20-
description: "Primary email address of the contact. If you want to associate additional email(s) with this contact, use the other_emails attribute.",
18+
label: "Email Address",
19+
description: "Primary email address of the contact",
2120
optional: true,
2221
},
2322
otherEmails: {
2423
type: "string[]",
25-
label: "Additional email addresses",
26-
description: "String array of additional email addresses.",
24+
label: "Additional Email Addresses",
25+
description: "One or more additional email addresses for the contact",
2726
optional: true,
2827
},
2928
phone: {
3029
type: "string",
31-
label: "Phone number",
32-
description: "Telephone number of the contact.",
30+
label: "Phone Number",
31+
description: "Phone number of the contact",
3332
optional: true,
3433
},
3534
companyId: {
@@ -41,16 +40,16 @@ export default {
4140
},
4241
},
4342
async run({ $ }) {
44-
const data = removeNullEntries({
45-
name: this.name,
46-
email: this.email,
47-
other_emails: this.otherEmails,
48-
phone: this.phone,
49-
company_id: this.companyId && Number(this.companyId),
50-
});
43+
const {
44+
companyId, otherEmails, ...data
45+
} = this;
5146
const response = await this.freshdesk.createContact({
5247
$,
53-
data,
48+
data: {
49+
other_emails: otherEmails,
50+
company_id: companyId && Number(companyId),
51+
...data,
52+
},
5453
});
5554
response && $.export("$summary", "Contact successfully created");
5655
return response;

components/freshdesk/actions/create-ticket/create-ticket.mjs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import freshdesk from "../../freshdesk.app.mjs";
2-
import { removeNullEntries } from "../../common/utils.mjs";
32

43
export default {
54
key: "freshdesk-create-ticket",
65
name: "Create a Ticket",
7-
description: "Create a ticket. [See docs here](https://developers.freshdesk.com/api/#tickets)",
8-
version: "0.0.2",
6+
description: "Create a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_ticket)",
7+
version: "0.0.3",
98
type: "action",
109
props: {
1110
freshdesk,
@@ -14,7 +13,6 @@ export default {
1413
freshdesk,
1514
"companyId",
1615
],
17-
description: "ID of the company to which this ticket belongs",
1816
},
1917
email: {
2018
propDefinition: [
@@ -24,7 +22,6 @@ export default {
2422
companyId,
2523
}),
2624
],
27-
description: "Email address of the requester.",
2825
optional: true,
2926
},
3027
priority: {
@@ -34,28 +31,28 @@ export default {
3431
],
3532
default: 1,
3633
},
34+
subject: {
35+
type: "string",
36+
label: "Subject",
37+
description: "Subject of the ticket",
38+
optional: true,
39+
},
3740
description: {
3841
type: "string",
3942
label: "Description",
40-
description: "HTML content of the ticket.",
43+
description: "HTML content of the ticket",
4144
optional: true,
4245
},
4346
descriptionText: {
4447
type: "string",
4548
label: "Description text",
46-
description: "Content of the ticket in plain text.",
49+
description: "Content of the ticket in plain text",
4750
optional: true,
4851
},
4952
phone: {
5053
type: "string",
5154
label: "Phone number",
52-
description: "Telephone number of the contact.",
53-
optional: true,
54-
},
55-
subject: {
56-
type: "string",
57-
label: "Subject",
58-
description: "Subject of the ticket.",
55+
description: "Phone number of the requester. If no contact exists with this phone number on Freshdesk, it will be added as a new contact",
5956
optional: true,
6057
},
6158
status: {
@@ -68,19 +65,16 @@ export default {
6865
},
6966
},
7067
async run({ $ }) {
71-
const data = removeNullEntries({
72-
company_id: this.companyId && Number(this.companyId),
73-
description: this.description,
74-
description_text: this.descriptionText,
75-
email: this.email,
76-
phone: this.phone,
77-
subject: this.subject,
78-
status: this.status && Number(this.status),
79-
priority: this.priority && Number(this.priority),
80-
});
81-
const response = await this.freshdesk.createTicket({
68+
const {
69+
freshdesk, companyId, descriptionText, ...data
70+
} = this;
71+
const response = await freshdesk.createTicket({
8272
$,
83-
data,
73+
data: {
74+
company_id: Number(companyId),
75+
description_text: descriptionText,
76+
...data,
77+
},
8478
});
8579
response && $.export("$summary", "Ticket successfully created");
8680
return response;

components/freshdesk/actions/get-ticket/get-ticket.mjs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,27 @@ import freshdesk from "../../freshdesk.app.mjs";
33
export default {
44
key: "freshdesk-get-ticket",
55
name: "Get Ticket Details",
6-
description: "Get a Ticket. [See docs here](https://developers.freshdesk.com/api/#tickets)",
7-
version: "0.0.1",
6+
description: "Get details of a Ticket. [See the documentation](https://developers.freshdesk.com/api/#view_a_ticket)",
7+
version: "0.1.0",
88
type: "action",
99
props: {
1010
freshdesk,
11-
id: {
12-
type: "string",
13-
label: "Ticket ID",
14-
description: "Ticket ID.",
11+
ticketId: {
12+
propDefinition: [
13+
freshdesk,
14+
"ticketId",
15+
],
1516
},
1617
},
1718
async run({ $ }) {
18-
const response = await this.freshdesk.getTicket({
19+
const {
20+
freshdesk, ticketId,
21+
} = this;
22+
const response = await freshdesk.getTicket({
1923
$,
20-
id: this.id,
24+
ticketId,
2125
});
22-
response && $.export("$summary", "Successfully found ticket");
26+
response && $.export("$summary", "Successfully retrieved ticket");
2327
return response;
2428
},
2529
};
Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,69 @@
1-
// legacy_hash_id: a_A6i5zz
2-
import { axios } from "@pipedream/platform";
1+
import freshdesk from "../../freshdesk.app.mjs";
32

43
export default {
54
key: "freshdesk-list-all-tickets",
6-
name: "List All Tickets",
7-
description: "Use filters to view only specific tickets (those which match the criteria that you choose). By default, only tickets that have not been deleted or marked as spam will be returned, unless you use the 'deleted' filter.",
8-
version: "0.1.1",
5+
name: "List Tickets",
6+
description:
7+
"Fetch up to 100 tickets according to the selected filters. [See the documentation](https://developers.freshdesk.com/api/#list_all_tickets)",
8+
version: "0.2.0",
99
type: "action",
1010
props: {
11-
freshdesk: {
12-
type: "app",
13-
app: "freshdesk",
11+
freshdesk,
12+
orderBy: {
13+
type: "string",
14+
label: "Sort By",
15+
description: "Which field to sort tickets by. Defaults to `Created At`",
16+
optional: true,
17+
options: [
18+
{
19+
value: "created_at",
20+
label: "Created At",
21+
},
22+
{
23+
value: "due_by",
24+
label: "Due By",
25+
},
26+
{
27+
value: "updated_at",
28+
label: "Updated At",
29+
},
30+
{
31+
value: "status",
32+
label: "Status",
33+
},
34+
],
35+
},
36+
orderType: {
37+
type: "string",
38+
label: "Sort Order",
39+
description:
40+
"Whether to sort in ascending or descending order. Defaults to descending",
41+
optional: true,
42+
options: [
43+
{
44+
label: "Ascending",
45+
value: "asc",
46+
},
47+
{
48+
label: "Descending",
49+
value: "desc",
50+
},
51+
],
1452
},
1553
},
1654
async run({ $ }) {
17-
return await axios($, {
18-
url: `https://${this.freshdesk.$auth.domain}.freshdesk.com/api/v2/tickets`,
19-
auth: {
20-
username: `${this.freshdesk.$auth.api_key}:X`,
21-
password: "",
55+
const response = await this.freshdesk.listTickets({
56+
$,
57+
params: {
58+
order_by: this.orderBy,
59+
order_type: this.orderType,
2260
},
2361
});
62+
63+
const { length } = response;
64+
$.export("$summary", `Successfully fetched ${length} ticket${length === 1
65+
? ""
66+
: "s"}`);
67+
return response;
2468
},
2569
};

components/freshdesk/common/constants.mjs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
export default {
2-
HTTP_PROTOCOL: "https://",
3-
BASE_PATH: "/api",
4-
VERSION_PATH: "/v2",
52
PAGE_SIZE: 100,
6-
retriableStatusCodes: [
7-
408,
8-
429,
9-
500,
10-
],
113
DB_LAST_DATE_CHECK: "DB_LAST_DATE_CHECK",
124
TICKET_STATUS: [
135
{

0 commit comments

Comments
 (0)