@pipedream/freshdesk 0.0.4 → 0.1.1

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 CHANGED
@@ -1,9 +1,11 @@
1
1
  # Overview
2
2
 
3
- With the Freshdesk API, you can create powerful customer support applications.
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
- - A ticketing system for tracking customer issues
7
- - A knowledge base for self-service customer support
8
- - A customer community for engaging customers and crowd-sourcing solutions
9
- - A call center management system
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 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.3",
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 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({
51
46
  $,
52
- payload,
47
+ data,
53
48
  });
54
- response && $.export("$summary", "Company sucessfully created");
49
+ response && $.export("$summary", "Company successfully created");
55
50
  return response;
56
51
  },
57
52
  };
@@ -1,11 +1,11 @@
1
- import { removeNullEntries } from "../../common/utils.mjs";
2
1
  import freshdesk from "../../freshdesk.app.mjs";
2
+ import { ConfigurationError } from "@pipedream/platform";
3
3
 
4
4
  export default {
5
5
  key: "freshdesk-create-contact",
6
6
  name: "Create a Contact",
7
- description: "Create a contact. [See docs here](https://developers.freshdesk.com/api/#create_contact)",
8
- version: "0.0.1",
7
+ description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)",
8
+ version: "0.0.3",
9
9
  type: "action",
10
10
  props: {
11
11
  freshdesk,
@@ -16,20 +16,20 @@ export default {
16
16
  },
17
17
  email: {
18
18
  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.",
19
+ label: "Email Address",
20
+ description: "Primary email address of the contact",
21
21
  optional: true,
22
22
  },
23
23
  otherEmails: {
24
24
  type: "string[]",
25
- label: "Additional email addresses",
26
- description: "String array of additional email addresses.",
25
+ label: "Additional Email Addresses",
26
+ description: "One or more additional email addresses for the contact",
27
27
  optional: true,
28
28
  },
29
29
  phone: {
30
30
  type: "string",
31
- label: "Phone number",
32
- description: "Telephone number of the contact.",
31
+ label: "Phone Number",
32
+ description: "Phone number of the contact",
33
33
  optional: true,
34
34
  },
35
35
  companyId: {
@@ -41,16 +41,21 @@ export default {
41
41
  },
42
42
  },
43
43
  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
- });
51
- const response = await this.freshdesk.createContact({
44
+ const {
45
+ freshdesk, companyId, otherEmails, ...data
46
+ } = this;
47
+
48
+ if (!this.email && !this.phone) {
49
+ throw new ConfigurationError("Must specify `email` and/or `phone`");
50
+ }
51
+
52
+ const response = await freshdesk.createContact({
52
53
  $,
53
- data,
54
+ data: {
55
+ other_emails: otherEmails,
56
+ company_id: companyId && Number(companyId),
57
+ ...data,
58
+ },
54
59
  });
55
60
  response && $.export("$summary", "Contact successfully created");
56
61
  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 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.4",
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,8 +22,6 @@ export default {
24
22
  companyId,
25
23
  }),
26
24
  ],
27
- description: "Email address of the requester.",
28
- optional: true,
29
25
  },
30
26
  priority: {
31
27
  propDefinition: [
@@ -33,29 +29,22 @@ export default {
33
29
  "ticketPriority",
34
30
  ],
35
31
  default: 1,
32
+ optional: true,
36
33
  },
37
- description: {
34
+ subject: {
38
35
  type: "string",
39
- label: "Description",
40
- description: "HTML content of the ticket.",
41
- optional: true,
36
+ label: "Subject",
37
+ description: "Subject of the ticket",
42
38
  },
43
- descriptionText: {
39
+ description: {
44
40
  type: "string",
45
- label: "Description text",
46
- description: "Content of the ticket in plain text.",
47
- optional: true,
41
+ label: "Description",
42
+ description: "HTML content of the ticket",
48
43
  },
49
44
  phone: {
50
45
  type: "string",
51
46
  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.",
47
+ 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
48
  optional: true,
60
49
  },
61
50
  status: {
@@ -68,19 +57,15 @@ export default {
68
57
  },
69
58
  },
70
59
  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({
60
+ const {
61
+ freshdesk, companyId, ...data
62
+ } = this;
63
+ const response = await freshdesk.createTicket({
82
64
  $,
83
- data,
65
+ data: {
66
+ company_id: Number(companyId),
67
+ ...data,
68
+ },
84
69
  });
85
70
  response && $.export("$summary", "Ticket successfully created");
86
71
  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 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.1",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
11
- id: {
12
- type: "string",
13
- label: "Ticket ID",
14
- description: "Ticket ID.",
11
+ ticketId: {
12
+ propDefinition: [
13
+ freshdesk,
14
+ "ticketId",
15
+ ],
15
16
  },
16
17
  },
17
18
  async run({ $ }) {
18
- const response = await this.freshdesk.getTicket({
19
+ const {
20
+ freshdesk, ticketId,
21
+ } = this;
22
+ const response = await freshdesk.getTicket({
19
23
  $,
20
- id: this.id,
24
+ ticketId,
21
25
  });
22
- response && $.export("$summary", "Successfully found ticket");
26
+ response && $.export("$summary", "Successfully retrieved ticket");
23
27
  return response;
24
28
  },
25
29
  };
@@ -1,25 +1,69 @@
1
- // legacy_hash_id: a_A6i5zz
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 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.1",
9
9
  type: "action",
10
10
  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
+ ],
14
52
  },
15
53
  },
16
54
  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,
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
  };
@@ -1,13 +1,5 @@
1
1
  export default {
2
- HTTP_PROTOCOL: "https://",
3
- BASE_PATH: "/api",
4
- VERSION_PATH: "/v2",
5
2
  PAGE_SIZE: 100,
6
- retriableStatusCodes: [
7
- 408,
8
- 429,
9
- 500,
10
- ],
11
3
  DB_LAST_DATE_CHECK: "DB_LAST_DATE_CHECK",
12
4
  TICKET_STATUS: [
13
5
  {
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: "The ID of the company",
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((project) => ({
18
- label: project.name,
19
- value: project.id,
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,21 @@ export default {
39
56
  contactEmail: {
40
57
  type: "string",
41
58
  label: "Email",
42
- description: "Contact Email.",
59
+ description: "Select a contact or provide a contact's email",
43
60
  async options({ companyId }) {
44
- const response = await this.getCompanies();
45
- const contacts = response.filter((contact) => contact.company_id === Number(companyId));
46
- return contacts.map((contact) => ({
47
- label: contact?.email ?? contact?.name,
48
- value: contact.email,
49
- }));
61
+ const contacts = await this.getContacts({
62
+ params: {
63
+ company_id: companyId,
64
+ },
65
+ });
66
+ return contacts
67
+ .filter(({ email }) => email)
68
+ .map(({
69
+ email, name,
70
+ }) => ({
71
+ label: name || email,
72
+ value: email,
73
+ }));
50
74
  },
51
75
  },
52
76
  },
@@ -66,64 +90,32 @@ export default {
66
90
  "Content-Type": "application/json;charset=utf-8",
67
91
  };
68
92
  },
69
- _getUrl(path) {
70
- const {
71
- HTTP_PROTOCOL,
72
- BASE_PATH,
73
- VERSION_PATH,
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);
93
+ _getDomain() {
94
+ const { domain } = this.$auth;
95
+ return domain.includes("freshdesk.com")
96
+ ? domain
97
+ : `${domain}.freshdesk.com`;
97
98
  },
98
- async _withRetries(apiCall) {
99
- const retryOpts = {
100
- retries: 5,
101
- factor: 2,
102
- };
103
- return retry(async (bail) => {
104
- try {
105
- const data = await apiCall();
106
-
107
- return data;
108
- } catch (err) {
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);
99
+ async _makeRequest({
100
+ $ = this, headers, ...args
101
+ }) {
102
+ return axios($, {
103
+ baseURL: `https://${this._getDomain()}/api/v2`,
104
+ headers: {
105
+ ...this._getHeaders(),
106
+ ...headers,
107
+ },
108
+ ...args,
109
+ });
120
110
  },
121
111
  async *filterTickets(params) {
122
112
  let loadedData = 0;
123
113
  do {
124
- const response = await this.searchTickets(params);
114
+ const response = await this.searchTickets({
115
+ params,
116
+ });
125
117
 
126
- if (!response || response.results.length === 0) {
118
+ if (!response?.results?.length) {
127
119
  return;
128
120
  }
129
121
  loadedData += response.results.length;
@@ -139,9 +131,11 @@ export default {
139
131
  async *filterContacts(params) {
140
132
  let loadedData = 0;
141
133
  do {
142
- const response = await this.searchContacts(params);
134
+ const response = await this.searchContacts({
135
+ params,
136
+ });
143
137
 
144
- if (!response || response.results.length === 0) {
138
+ if (!response?.results?.length) {
145
139
  return;
146
140
  }
147
141
  loadedData += response.results.length;
@@ -154,68 +148,63 @@ export default {
154
148
  params.page += 1;
155
149
  } while (true);
156
150
  },
157
- async createCompany({
158
- $, payload: data,
159
- }) {
151
+ async createCompany(args) {
160
152
  return this._makeRequest({
161
- $,
162
- path: "/companies",
163
- data,
153
+ url: "/companies",
164
154
  method: "post",
155
+ ...args,
165
156
  });
166
157
  },
167
- async getCompanies($ = undefined) {
158
+ async getCompanies(args) {
168
159
  return this._makeRequest({
169
- $,
170
- path: "/contacts",
160
+ url: "/companies",
161
+ ...args,
171
162
  });
172
163
  },
173
- async getContacts($ = undefined) {
164
+ async getContacts(args) {
174
165
  return this._makeRequest({
175
- $,
176
- path: "/companies",
166
+ url: "/contacts",
167
+ ...args,
177
168
  });
178
169
  },
179
- async createContact({
180
- $, data,
181
- }) {
170
+ async createContact(args) {
182
171
  return this._makeRequest({
183
- $,
184
- path: "/contacts",
185
- data,
172
+ url: "/contacts",
186
173
  method: "post",
174
+ ...args,
187
175
  });
188
176
  },
189
- async createTicket({
190
- $, data,
191
- }) {
177
+ async createTicket(args) {
192
178
  return this._makeRequest({
193
- $,
194
- path: "/tickets",
195
- data,
179
+ url: "/tickets",
196
180
  method: "post",
181
+ ...args,
197
182
  });
198
183
  },
199
184
  async getTicket({
200
- $, id,
185
+ ticketId, ...args
201
186
  }) {
202
187
  return this._makeRequest({
203
- $,
204
- path: `/tickets/${id}`,
188
+ url: `/tickets/${ticketId}`,
189
+ ...args,
190
+ });
191
+ },
192
+ async searchTickets(args) {
193
+ return this._makeRequest({
194
+ url: "/search/tickets",
195
+ ...args,
205
196
  });
206
197
  },
207
- async searchTickets(params, $ = undefined) {
198
+ async searchContacts(args) {
208
199
  return this._makeRequest({
209
- $,
210
- path: "/search/tickets",
211
- params,
200
+ url: "/search/contacts",
201
+ ...args,
212
202
  });
213
203
  },
214
- async searchContacts(params, $ = undefined) {
204
+ async listTickets(args) {
215
205
  return this._makeRequest({
216
- $,
217
- path: "/search/contacts",
218
- params,
206
+ url: "/tickets",
207
+ ...args,
219
208
  });
220
209
  },
221
210
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/freshdesk",
3
- "version": "0.0.4",
3
+ "version": "0.1.1",
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": "^1.2.0",
16
+ "@pipedream/platform": "^3.0.3",
17
17
  "async-retry": "^1.3.3",
18
- "moment": "2.29.2"
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 notifications when a new contact is created",
9
- version: "0.0.2",
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.4",
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 name: ${contact.name}`,
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 notifications when a new ticket is created",
9
- version: "0.0.2",
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.4",
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(0, (lastDateChecked + "T").indexOf("T"));
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 && data.reverse().forEach((ticket) => {
40
- this.freshdesk.setLastDateChecked(this.db, ticket.created_at);
41
- if (moment(ticket.created_at).isAfter(lastDateChecked)) {
42
- this.$emit(ticket,
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 number: ${ticket.id}`,
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
  };