@pipedream/freshdesk 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/actions/create-company/create-company.mjs +12 -17
- package/actions/create-contact/create-contact.mjs +16 -17
- package/actions/create-ticket/create-ticket.mjs +20 -26
- package/actions/get-ticket/get-ticket.mjs +13 -9
- package/actions/list-all-tickets/list-all-tickets.mjs +57 -13
- package/common/constants.mjs +0 -8
- package/freshdesk.app.mjs +92 -106
- package/package.json +3 -3
- package/sources/new-contact/new-contact.mjs +4 -6
- package/sources/new-ticket/new-ticket.mjs +15 -14
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# Overview
|
|
2
2
|
|
|
3
|
-
With
|
|
4
|
-
Here are some examples of what you can build:
|
|
3
|
+
The Freshdesk API empowers you to interact programmatically with your customer support platform, creating possibilities for automating repetitive tasks, integrating with other services, and enhancing customer experiences. With Pipedream, you can effortlessly connect Freshdesk to a multitude of apps, tapping into triggers and actions that streamline workflows. For instance, you can automate ticket creation, sync customer issues with a CRM, or trigger notifications based on ticket updates, all within a serverless environment.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
|
|
5
|
+
# Example Use Cases
|
|
6
|
+
|
|
7
|
+
- **Auto-ticket Generation from Emails**: When an email arrives at a specific mailbox, Pipedream can capture that event and use the Freshdesk API to create a new support ticket. This ensures that no customer query goes unanswered and allows support teams to manage all requests from Freshdesk's centralized interface.
|
|
8
|
+
|
|
9
|
+
- **CRM Sync with Ticket Updates**: Once a ticket in Freshdesk is updated—be it a status change, priority update, or note addition—a Pipedream workflow can push these updates to a connected CRM, like Salesforce. This keeps sales and support teams aligned on customer interactions, providing a seamless customer service experience.
|
|
10
|
+
|
|
11
|
+
- **Slack Notifications for Urgent Tickets**: Using Pipedream's integration with Slack, build a workflow that listens for new tickets tagged as 'urgent' in Freshdesk. Then, automatically send a message to a designated Slack channel or direct message to a team member, ensuring immediate attention is given to critical support issues.
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import { removeNullEntries } from "../../common/utils.mjs";
|
|
2
1
|
import freshdesk from "../../freshdesk.app.mjs";
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
key: "freshdesk-create-company",
|
|
6
5
|
name: "Create a Company",
|
|
7
|
-
description: "Create a company. [See
|
|
8
|
-
version: "0.0.
|
|
6
|
+
description: "Create a company. [See the documentation](https://developers.freshdesk.com/api/#create_company)",
|
|
7
|
+
version: "0.0.2",
|
|
9
8
|
type: "action",
|
|
10
9
|
props: {
|
|
11
10
|
freshdesk,
|
|
12
11
|
name: {
|
|
13
12
|
type: "string",
|
|
14
13
|
label: "Name",
|
|
15
|
-
description: "Name of the company
|
|
14
|
+
description: "Name of the company",
|
|
16
15
|
},
|
|
17
16
|
description: {
|
|
18
17
|
type: "string",
|
|
19
18
|
label: "Description",
|
|
20
|
-
description: "Description of the company
|
|
19
|
+
description: "Description of the company",
|
|
21
20
|
optional: true,
|
|
22
21
|
},
|
|
23
22
|
note: {
|
|
24
23
|
type: "string",
|
|
25
24
|
label: "Note",
|
|
26
|
-
description: "Any specific note about the company
|
|
25
|
+
description: "Any specific note about the company",
|
|
27
26
|
optional: true,
|
|
28
27
|
},
|
|
29
28
|
industry: {
|
|
30
29
|
type: "string",
|
|
31
30
|
label: "Industry",
|
|
32
|
-
description: "The industry the company serves in
|
|
31
|
+
description: "The industry the company serves in",
|
|
33
32
|
optional: true,
|
|
34
33
|
},
|
|
35
34
|
domains: {
|
|
@@ -40,18 +39,14 @@ export default {
|
|
|
40
39
|
},
|
|
41
40
|
},
|
|
42
41
|
async run({ $ }) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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({
|
|
51
46
|
$,
|
|
52
|
-
|
|
47
|
+
data,
|
|
53
48
|
});
|
|
54
|
-
response && $.export("$summary", "Company
|
|
49
|
+
response && $.export("$summary", "Company successfully created");
|
|
55
50
|
return response;
|
|
56
51
|
},
|
|
57
52
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { removeNullEntries } from "../../common/utils.mjs";
|
|
2
1
|
import freshdesk from "../../freshdesk.app.mjs";
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
key: "freshdesk-create-contact",
|
|
6
5
|
name: "Create a Contact",
|
|
7
|
-
description: "Create a contact. [See
|
|
8
|
-
version: "0.0.
|
|
6
|
+
description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)",
|
|
7
|
+
version: "0.0.2",
|
|
9
8
|
type: "action",
|
|
10
9
|
props: {
|
|
11
10
|
freshdesk,
|
|
@@ -16,20 +15,20 @@ export default {
|
|
|
16
15
|
},
|
|
17
16
|
email: {
|
|
18
17
|
type: "string",
|
|
19
|
-
label: "Email",
|
|
20
|
-
description: "Primary email address of the contact
|
|
18
|
+
label: "Email Address",
|
|
19
|
+
description: "Primary email address of the contact",
|
|
21
20
|
optional: true,
|
|
22
21
|
},
|
|
23
22
|
otherEmails: {
|
|
24
23
|
type: "string[]",
|
|
25
|
-
label: "Additional
|
|
26
|
-
description: "
|
|
24
|
+
label: "Additional Email Addresses",
|
|
25
|
+
description: "One or more additional email addresses for the contact",
|
|
27
26
|
optional: true,
|
|
28
27
|
},
|
|
29
28
|
phone: {
|
|
30
29
|
type: "string",
|
|
31
|
-
label: "Phone
|
|
32
|
-
description: "
|
|
30
|
+
label: "Phone Number",
|
|
31
|
+
description: "Phone number of the contact",
|
|
33
32
|
optional: true,
|
|
34
33
|
},
|
|
35
34
|
companyId: {
|
|
@@ -41,16 +40,16 @@ export default {
|
|
|
41
40
|
},
|
|
42
41
|
},
|
|
43
42
|
async run({ $ }) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
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;
|
|
51
46
|
const response = await this.freshdesk.createContact({
|
|
52
47
|
$,
|
|
53
|
-
data
|
|
48
|
+
data: {
|
|
49
|
+
other_emails: otherEmails,
|
|
50
|
+
company_id: companyId && Number(companyId),
|
|
51
|
+
...data,
|
|
52
|
+
},
|
|
54
53
|
});
|
|
55
54
|
response && $.export("$summary", "Contact successfully created");
|
|
56
55
|
return response;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import freshdesk from "../../freshdesk.app.mjs";
|
|
2
|
-
import { removeNullEntries } from "../../common/utils.mjs";
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
key: "freshdesk-create-ticket",
|
|
6
5
|
name: "Create a Ticket",
|
|
7
|
-
description: "Create a ticket. [See
|
|
8
|
-
version: "0.0.
|
|
6
|
+
description: "Create a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_ticket)",
|
|
7
|
+
version: "0.0.3",
|
|
9
8
|
type: "action",
|
|
10
9
|
props: {
|
|
11
10
|
freshdesk,
|
|
@@ -14,7 +13,6 @@ export default {
|
|
|
14
13
|
freshdesk,
|
|
15
14
|
"companyId",
|
|
16
15
|
],
|
|
17
|
-
description: "ID of the company to which this ticket belongs",
|
|
18
16
|
},
|
|
19
17
|
email: {
|
|
20
18
|
propDefinition: [
|
|
@@ -24,7 +22,6 @@ export default {
|
|
|
24
22
|
companyId,
|
|
25
23
|
}),
|
|
26
24
|
],
|
|
27
|
-
description: "Email address of the requester.",
|
|
28
25
|
optional: true,
|
|
29
26
|
},
|
|
30
27
|
priority: {
|
|
@@ -34,28 +31,28 @@ export default {
|
|
|
34
31
|
],
|
|
35
32
|
default: 1,
|
|
36
33
|
},
|
|
34
|
+
subject: {
|
|
35
|
+
type: "string",
|
|
36
|
+
label: "Subject",
|
|
37
|
+
description: "Subject of the ticket",
|
|
38
|
+
optional: true,
|
|
39
|
+
},
|
|
37
40
|
description: {
|
|
38
41
|
type: "string",
|
|
39
42
|
label: "Description",
|
|
40
|
-
description: "HTML content of the ticket
|
|
43
|
+
description: "HTML content of the ticket",
|
|
41
44
|
optional: true,
|
|
42
45
|
},
|
|
43
46
|
descriptionText: {
|
|
44
47
|
type: "string",
|
|
45
48
|
label: "Description text",
|
|
46
|
-
description: "Content of the ticket in plain text
|
|
49
|
+
description: "Content of the ticket in plain text",
|
|
47
50
|
optional: true,
|
|
48
51
|
},
|
|
49
52
|
phone: {
|
|
50
53
|
type: "string",
|
|
51
54
|
label: "Phone number",
|
|
52
|
-
description: "
|
|
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",
|
|
59
56
|
optional: true,
|
|
60
57
|
},
|
|
61
58
|
status: {
|
|
@@ -68,19 +65,16 @@ export default {
|
|
|
68
65
|
},
|
|
69
66
|
},
|
|
70
67
|
async run({ $ }) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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({
|
|
82
72
|
$,
|
|
83
|
-
data
|
|
73
|
+
data: {
|
|
74
|
+
company_id: Number(companyId),
|
|
75
|
+
description_text: descriptionText,
|
|
76
|
+
...data,
|
|
77
|
+
},
|
|
84
78
|
});
|
|
85
79
|
response && $.export("$summary", "Ticket successfully created");
|
|
86
80
|
return response;
|
|
@@ -3,23 +3,27 @@ import freshdesk from "../../freshdesk.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
key: "freshdesk-get-ticket",
|
|
5
5
|
name: "Get Ticket Details",
|
|
6
|
-
description: "Get a Ticket. [See
|
|
7
|
-
version: "0.0
|
|
6
|
+
description: "Get details of a Ticket. [See the documentation](https://developers.freshdesk.com/api/#view_a_ticket)",
|
|
7
|
+
version: "0.1.0",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
freshdesk,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
ticketId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
freshdesk,
|
|
14
|
+
"ticketId",
|
|
15
|
+
],
|
|
15
16
|
},
|
|
16
17
|
},
|
|
17
18
|
async run({ $ }) {
|
|
18
|
-
const
|
|
19
|
+
const {
|
|
20
|
+
freshdesk, ticketId,
|
|
21
|
+
} = this;
|
|
22
|
+
const response = await freshdesk.getTicket({
|
|
19
23
|
$,
|
|
20
|
-
|
|
24
|
+
ticketId,
|
|
21
25
|
});
|
|
22
|
-
response && $.export("$summary", "Successfully
|
|
26
|
+
response && $.export("$summary", "Successfully retrieved ticket");
|
|
23
27
|
return response;
|
|
24
28
|
},
|
|
25
29
|
};
|
|
@@ -1,25 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
import { axios } from "@pipedream/platform";
|
|
1
|
+
import freshdesk from "../../freshdesk.app.mjs";
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
key: "freshdesk-list-all-tickets",
|
|
6
|
-
name: "List
|
|
7
|
-
description:
|
|
8
|
-
|
|
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",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
|
-
freshdesk
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
],
|
|
14
52
|
},
|
|
15
53
|
},
|
|
16
54
|
async run({ $ }) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
55
|
+
const response = await this.freshdesk.listTickets({
|
|
56
|
+
$,
|
|
57
|
+
params: {
|
|
58
|
+
order_by: this.orderBy,
|
|
59
|
+
order_type: this.orderType,
|
|
22
60
|
},
|
|
23
61
|
});
|
|
62
|
+
|
|
63
|
+
const { length } = response;
|
|
64
|
+
$.export("$summary", `Successfully fetched ${length} ticket${length === 1
|
|
65
|
+
? ""
|
|
66
|
+
: "s"}`);
|
|
67
|
+
return response;
|
|
24
68
|
},
|
|
25
69
|
};
|
package/common/constants.mjs
CHANGED
package/freshdesk.app.mjs
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import constants from "./common/constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
axios, ConfigurationError,
|
|
4
|
-
} from "@pipedream/platform";
|
|
5
|
-
import retry from "async-retry";
|
|
2
|
+
import { axios } from "@pipedream/platform";
|
|
6
3
|
|
|
7
4
|
export default {
|
|
8
5
|
type: "app",
|
|
@@ -11,19 +8,39 @@ export default {
|
|
|
11
8
|
companyId: {
|
|
12
9
|
type: "integer",
|
|
13
10
|
label: "Company ID",
|
|
14
|
-
description: "
|
|
11
|
+
description: "Select a company or provide a company ID",
|
|
15
12
|
async options() {
|
|
16
13
|
const response = await this.getCompanies();
|
|
17
|
-
return response.map((
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
return response.map(({
|
|
15
|
+
id, name,
|
|
16
|
+
}) => ({
|
|
17
|
+
label: name || id,
|
|
18
|
+
value: id,
|
|
19
|
+
}));
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
ticketId: {
|
|
23
|
+
type: "integer",
|
|
24
|
+
label: "Ticket ID",
|
|
25
|
+
description: "Select a ticket or provide a ticket ID",
|
|
26
|
+
async options({ page = 0 }) {
|
|
27
|
+
const response = await this.listTickets({
|
|
28
|
+
params: {
|
|
29
|
+
page: page + 1,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return response.map(({
|
|
33
|
+
id, subject,
|
|
34
|
+
}) => ({
|
|
35
|
+
label: subject || id,
|
|
36
|
+
value: id,
|
|
20
37
|
}));
|
|
21
38
|
},
|
|
22
39
|
},
|
|
23
40
|
ticketStatus: {
|
|
24
41
|
type: "integer",
|
|
25
42
|
label: "Status",
|
|
26
|
-
description: "Status of the ticket
|
|
43
|
+
description: "Status of the ticket",
|
|
27
44
|
options() {
|
|
28
45
|
return constants.TICKET_STATUS;
|
|
29
46
|
},
|
|
@@ -31,7 +48,7 @@ export default {
|
|
|
31
48
|
ticketPriority: {
|
|
32
49
|
type: "integer",
|
|
33
50
|
label: "Priority",
|
|
34
|
-
description: "Priority of the ticket
|
|
51
|
+
description: "Priority of the ticket",
|
|
35
52
|
options() {
|
|
36
53
|
return constants.TICKET_PRIORITY;
|
|
37
54
|
},
|
|
@@ -39,14 +56,18 @@ export default {
|
|
|
39
56
|
contactEmail: {
|
|
40
57
|
type: "string",
|
|
41
58
|
label: "Email",
|
|
42
|
-
description: "
|
|
59
|
+
description: "Select a contact or provide a contact's email",
|
|
43
60
|
async options({ companyId }) {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
return contacts
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
const contacts = await this.getContacts();
|
|
62
|
+
const numId = Number(companyId);
|
|
63
|
+
return contacts
|
|
64
|
+
.filter((contact) => contact.company_id === numId)
|
|
65
|
+
.map(({
|
|
66
|
+
email, name,
|
|
67
|
+
}) => ({
|
|
68
|
+
label: name || email,
|
|
69
|
+
value: email,
|
|
70
|
+
}));
|
|
50
71
|
},
|
|
51
72
|
},
|
|
52
73
|
},
|
|
@@ -66,64 +87,32 @@ export default {
|
|
|
66
87
|
"Content-Type": "application/json;charset=utf-8",
|
|
67
88
|
};
|
|
68
89
|
},
|
|
69
|
-
|
|
70
|
-
const {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
} = constants;
|
|
75
|
-
return `${HTTP_PROTOCOL}${this.$auth.domain}${BASE_PATH}${VERSION_PATH}${path}`;
|
|
76
|
-
},
|
|
77
|
-
async _makeRequest(args = {}) {
|
|
78
|
-
const {
|
|
79
|
-
$,
|
|
80
|
-
method = "get",
|
|
81
|
-
path,
|
|
82
|
-
params,
|
|
83
|
-
data,
|
|
84
|
-
} = args;
|
|
85
|
-
const config = {
|
|
86
|
-
method,
|
|
87
|
-
url: this._getUrl(path),
|
|
88
|
-
headers: this._getHeaders(),
|
|
89
|
-
params,
|
|
90
|
-
data,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
return axios($ ?? this, config);
|
|
94
|
-
},
|
|
95
|
-
_isRetriableStatusCode(statusCode) {
|
|
96
|
-
constants.retriableStatusCodes.includes(statusCode);
|
|
90
|
+
_getDomain() {
|
|
91
|
+
const { domain } = this.$auth;
|
|
92
|
+
return domain.includes("freshdesk.com")
|
|
93
|
+
? domain
|
|
94
|
+
: `${domain}.freshdesk.com`;
|
|
97
95
|
},
|
|
98
|
-
async
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const { status = 500 } = err;
|
|
111
|
-
if (!this._isRetriableStatusCode(status)) {
|
|
112
|
-
bail(`
|
|
113
|
-
Unexpected error (status code: ${status}):
|
|
114
|
-
${JSON.stringify(err.response)}
|
|
115
|
-
`);
|
|
116
|
-
}
|
|
117
|
-
throw new ConfigurationError("Could not get data");
|
|
118
|
-
}
|
|
119
|
-
}, retryOpts);
|
|
96
|
+
async _makeRequest({
|
|
97
|
+
$ = this, headers, ...args
|
|
98
|
+
}) {
|
|
99
|
+
return axios($, {
|
|
100
|
+
baseURL: `https://${this._getDomain()}/api/v2`,
|
|
101
|
+
headers: {
|
|
102
|
+
...this._getHeaders(),
|
|
103
|
+
...headers,
|
|
104
|
+
},
|
|
105
|
+
...args,
|
|
106
|
+
});
|
|
120
107
|
},
|
|
121
108
|
async *filterTickets(params) {
|
|
122
109
|
let loadedData = 0;
|
|
123
110
|
do {
|
|
124
|
-
const response = await this.searchTickets(
|
|
111
|
+
const response = await this.searchTickets({
|
|
112
|
+
params,
|
|
113
|
+
});
|
|
125
114
|
|
|
126
|
-
if (!response
|
|
115
|
+
if (!response?.results?.length) {
|
|
127
116
|
return;
|
|
128
117
|
}
|
|
129
118
|
loadedData += response.results.length;
|
|
@@ -139,9 +128,11 @@ export default {
|
|
|
139
128
|
async *filterContacts(params) {
|
|
140
129
|
let loadedData = 0;
|
|
141
130
|
do {
|
|
142
|
-
const response = await this.searchContacts(
|
|
131
|
+
const response = await this.searchContacts({
|
|
132
|
+
params,
|
|
133
|
+
});
|
|
143
134
|
|
|
144
|
-
if (!response
|
|
135
|
+
if (!response?.results?.length) {
|
|
145
136
|
return;
|
|
146
137
|
}
|
|
147
138
|
loadedData += response.results.length;
|
|
@@ -154,68 +145,63 @@ export default {
|
|
|
154
145
|
params.page += 1;
|
|
155
146
|
} while (true);
|
|
156
147
|
},
|
|
157
|
-
async createCompany({
|
|
158
|
-
$, payload: data,
|
|
159
|
-
}) {
|
|
148
|
+
async createCompany(args) {
|
|
160
149
|
return this._makeRequest({
|
|
161
|
-
|
|
162
|
-
path: "/companies",
|
|
163
|
-
data,
|
|
150
|
+
url: "/companies",
|
|
164
151
|
method: "post",
|
|
152
|
+
...args,
|
|
165
153
|
});
|
|
166
154
|
},
|
|
167
|
-
async getCompanies(
|
|
155
|
+
async getCompanies(args) {
|
|
168
156
|
return this._makeRequest({
|
|
169
|
-
|
|
170
|
-
|
|
157
|
+
url: "/companies",
|
|
158
|
+
...args,
|
|
171
159
|
});
|
|
172
160
|
},
|
|
173
|
-
async getContacts(
|
|
161
|
+
async getContacts(args) {
|
|
174
162
|
return this._makeRequest({
|
|
175
|
-
|
|
176
|
-
|
|
163
|
+
url: "/contacts",
|
|
164
|
+
...args,
|
|
177
165
|
});
|
|
178
166
|
},
|
|
179
|
-
async createContact({
|
|
180
|
-
$, data,
|
|
181
|
-
}) {
|
|
167
|
+
async createContact(args) {
|
|
182
168
|
return this._makeRequest({
|
|
183
|
-
|
|
184
|
-
path: "/contacts",
|
|
185
|
-
data,
|
|
169
|
+
url: "/contacts",
|
|
186
170
|
method: "post",
|
|
171
|
+
...args,
|
|
187
172
|
});
|
|
188
173
|
},
|
|
189
|
-
async createTicket({
|
|
190
|
-
$, data,
|
|
191
|
-
}) {
|
|
174
|
+
async createTicket(args) {
|
|
192
175
|
return this._makeRequest({
|
|
193
|
-
|
|
194
|
-
path: "/tickets",
|
|
195
|
-
data,
|
|
176
|
+
url: "/tickets",
|
|
196
177
|
method: "post",
|
|
178
|
+
...args,
|
|
197
179
|
});
|
|
198
180
|
},
|
|
199
181
|
async getTicket({
|
|
200
|
-
|
|
182
|
+
ticketId, ...args
|
|
201
183
|
}) {
|
|
202
184
|
return this._makeRequest({
|
|
203
|
-
|
|
204
|
-
|
|
185
|
+
url: `/tickets/${ticketId}`,
|
|
186
|
+
...args,
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
async searchTickets(args) {
|
|
190
|
+
return this._makeRequest({
|
|
191
|
+
url: "/search/tickets",
|
|
192
|
+
...args,
|
|
205
193
|
});
|
|
206
194
|
},
|
|
207
|
-
async
|
|
195
|
+
async searchContacts(args) {
|
|
208
196
|
return this._makeRequest({
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
params,
|
|
197
|
+
url: "/search/contacts",
|
|
198
|
+
...args,
|
|
212
199
|
});
|
|
213
200
|
},
|
|
214
|
-
async
|
|
201
|
+
async listTickets(args) {
|
|
215
202
|
return this._makeRequest({
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
params,
|
|
203
|
+
url: "/tickets",
|
|
204
|
+
...args,
|
|
219
205
|
});
|
|
220
206
|
},
|
|
221
207
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/freshdesk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pipedream Freshdesk Components",
|
|
5
5
|
"main": "freshdesk.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@pipedream/platform": "^
|
|
16
|
+
"@pipedream/platform": "^3.0.3",
|
|
17
17
|
"async-retry": "^1.3.3",
|
|
18
|
-
"moment": "2.29.
|
|
18
|
+
"moment": "2.29.4"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -4,15 +4,13 @@ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
key: "freshdesk-new-contact",
|
|
7
|
-
name: "New Contact",
|
|
8
|
-
description: "Emit new
|
|
9
|
-
version: "0.0.
|
|
7
|
+
name: "New Contact Created",
|
|
8
|
+
description: "Emit new event when a contact is created. [See the documentation](https://developers.freshdesk.com/api/#filter_contacts)",
|
|
9
|
+
version: "0.0.3",
|
|
10
10
|
type: "source",
|
|
11
11
|
props: {
|
|
12
12
|
freshdesk,
|
|
13
13
|
timer: {
|
|
14
|
-
label: "Polling interval",
|
|
15
|
-
description: "Pipedream will poll Harvest API on this schedule",
|
|
16
14
|
type: "$.interface.timer",
|
|
17
15
|
default: {
|
|
18
16
|
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
@@ -42,7 +40,7 @@ export default {
|
|
|
42
40
|
this.$emit(contact,
|
|
43
41
|
{
|
|
44
42
|
id: contact.id,
|
|
45
|
-
summary: `Contact
|
|
43
|
+
summary: `New Contact: "${contact.name}"`,
|
|
46
44
|
ts: Date.parse(contact.created_at),
|
|
47
45
|
});
|
|
48
46
|
}
|
|
@@ -4,15 +4,13 @@ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
key: "freshdesk-new-ticket",
|
|
7
|
-
name: "New Ticket",
|
|
8
|
-
description: "Emit new
|
|
9
|
-
version: "0.0.
|
|
7
|
+
name: "New Ticket Created",
|
|
8
|
+
description: "Emit new event when a ticket is created. [See the documentation](https://developers.freshdesk.com/api/#filter_tickets)",
|
|
9
|
+
version: "0.0.3",
|
|
10
10
|
type: "source",
|
|
11
11
|
props: {
|
|
12
12
|
freshdesk,
|
|
13
13
|
timer: {
|
|
14
|
-
label: "Polling interval",
|
|
15
|
-
description: "Pipedream will poll Harvest API on this schedule",
|
|
16
14
|
type: "$.interface.timer",
|
|
17
15
|
default: {
|
|
18
16
|
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
@@ -28,7 +26,10 @@ export default {
|
|
|
28
26
|
lastDateChecked = new Date().toISOString();
|
|
29
27
|
this.freshdesk.setLastDateChecked(this.db, lastDateChecked);
|
|
30
28
|
}
|
|
31
|
-
const formatedDate = lastDateChecked.substr(
|
|
29
|
+
const formatedDate = lastDateChecked.substr(
|
|
30
|
+
0,
|
|
31
|
+
(lastDateChecked + "T").indexOf("T"),
|
|
32
|
+
);
|
|
32
33
|
const tickets = await this.freshdesk.filterTickets({
|
|
33
34
|
query: `"created_at:>'${formatedDate}'"`,
|
|
34
35
|
page: 1,
|
|
@@ -36,16 +37,16 @@ export default {
|
|
|
36
37
|
for await (const ticket of tickets) {
|
|
37
38
|
data.push(ticket);
|
|
38
39
|
}
|
|
39
|
-
data &&
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{
|
|
40
|
+
data &&
|
|
41
|
+
data.reverse().forEach((ticket) => {
|
|
42
|
+
this.freshdesk.setLastDateChecked(this.db, ticket.created_at);
|
|
43
|
+
if (moment(ticket.created_at).isAfter(lastDateChecked)) {
|
|
44
|
+
this.$emit(ticket, {
|
|
44
45
|
id: ticket.id,
|
|
45
|
-
summary: `Ticket
|
|
46
|
+
summary: `New Ticket (ID: ${ticket.id})`,
|
|
46
47
|
ts: Date.parse(ticket.created_at),
|
|
47
48
|
});
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
}
|
|
50
|
+
});
|
|
50
51
|
},
|
|
51
52
|
};
|