@pipedream/freshdesk 0.2.0 → 0.3.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.
@@ -0,0 +1,45 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+ import { ConfigurationError } from "@pipedream/platform";
3
+
4
+ export default {
5
+ key: "freshdesk-add-ticket-tags",
6
+ name: "Add Ticket Tags",
7
+ description: "Add tags to a ticket (appends to existing tags). [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
8
+ type: "action",
9
+ version: "0.0.1",
10
+ props: {
11
+ freshdesk,
12
+ ticketId: {
13
+ propDefinition: [
14
+ freshdesk,
15
+ "ticketId",
16
+ ],
17
+ },
18
+ ticketTags: {
19
+ propDefinition: [
20
+ freshdesk,
21
+ "ticketTags",
22
+ ],
23
+ description: "Array of tags to add to the ticket. These will be added to any existing tags.",
24
+ },
25
+ },
26
+ async run({ $ }) {
27
+ const {
28
+ ticketId,
29
+ ticketTags,
30
+ } = this;
31
+
32
+ if (!ticketTags || ticketTags.length === 0) {
33
+ throw new ConfigurationError("At least one tag must be provided");
34
+ }
35
+
36
+ const response = await this.freshdesk.addTicketTags({
37
+ ticketId,
38
+ tags: ticketTags,
39
+ $,
40
+ });
41
+
42
+ $.export("$summary", `Successfully added ${ticketTags.length} tag(s) to ticket ${ticketId}`);
43
+ return response;
44
+ },
45
+ };
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-assign-ticket-to-agent",
5
5
  name: "Assign Ticket to Agent",
6
6
  description: "Assign a Freshdesk ticket to a specific agent. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-assign-ticket-to-group",
5
5
  name: "Assign Ticket to Group",
6
6
  description: "Assign a Freshdesk ticket to a specific group [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-close-ticket",
5
5
  name: "Close Ticket",
6
6
  description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-create-company",
5
5
  name: "Create a Company",
6
6
  description: "Create a company. [See the documentation](https://developers.freshdesk.com/api/#create_company)",
7
- version: "0.0.4",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "freshdesk-create-contact",
6
6
  name: "Create a Contact",
7
7
  description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)",
8
- version: "0.0.4",
8
+ version: "0.0.5",
9
9
  type: "action",
10
10
  props: {
11
11
  freshdesk,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-create-ticket",
5
5
  name: "Create a Ticket",
6
6
  description: "Create a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_ticket)",
7
- version: "0.0.5",
7
+ version: "0.0.6",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-get-ticket",
5
5
  name: "Get Ticket Details",
6
6
  description: "Get details of a Ticket. [See the documentation](https://developers.freshdesk.com/api/#view_a_ticket)",
7
- version: "0.1.2",
7
+ version: "0.1.3",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -5,7 +5,7 @@ export default {
5
5
  name: "List Tickets",
6
6
  description:
7
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.2",
8
+ version: "0.2.3",
9
9
  type: "action",
10
10
  props: {
11
11
  freshdesk,
@@ -0,0 +1,45 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+ import { ConfigurationError } from "@pipedream/platform";
3
+
4
+ export default {
5
+ key: "freshdesk-remove-ticket-tags",
6
+ name: "Remove Ticket Tags",
7
+ description: "Remove specific tags from a ticket. [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
8
+ type: "action",
9
+ version: "0.0.1",
10
+ props: {
11
+ freshdesk,
12
+ ticketId: {
13
+ propDefinition: [
14
+ freshdesk,
15
+ "ticketId",
16
+ ],
17
+ },
18
+ ticketTags: {
19
+ propDefinition: [
20
+ freshdesk,
21
+ "ticketTags",
22
+ ],
23
+ description: "Array of tags to remove from the ticket. Only these specific tags will be removed.",
24
+ },
25
+ },
26
+ async run({ $ }) {
27
+ const {
28
+ ticketId,
29
+ ticketTags,
30
+ } = this;
31
+
32
+ if (!ticketTags || ticketTags.length === 0) {
33
+ throw new ConfigurationError("At least one tag must be provided");
34
+ }
35
+
36
+ const response = await this.freshdesk.removeTicketTags({
37
+ ticketId,
38
+ tags: ticketTags,
39
+ $,
40
+ });
41
+
42
+ $.export("$summary", `Successfully removed ${ticketTags.length} tag(s) from ticket ${ticketId}`);
43
+ return response;
44
+ },
45
+ };
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-set-ticket-priority",
5
5
  name: "Set Ticket Priority",
6
6
  description: "Update the priority of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-set-ticket-status",
5
5
  name: "Set Ticket Status",
6
6
  description: "Update the status of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -0,0 +1,45 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+ import { ConfigurationError } from "@pipedream/platform";
3
+
4
+ export default {
5
+ key: "freshdesk-set-ticket-tags",
6
+ name: "Set Ticket Tags",
7
+ description: "Set tags on a ticket (replaces all existing tags). [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
8
+ type: "action",
9
+ version: "0.0.1",
10
+ props: {
11
+ freshdesk,
12
+ ticketId: {
13
+ propDefinition: [
14
+ freshdesk,
15
+ "ticketId",
16
+ ],
17
+ },
18
+ ticketTags: {
19
+ propDefinition: [
20
+ freshdesk,
21
+ "ticketTags",
22
+ ],
23
+ description: "Array of tags to set on the ticket. This will replace all existing tags.",
24
+ },
25
+ },
26
+ async run({ $ }) {
27
+ const {
28
+ ticketId,
29
+ ticketTags,
30
+ } = this;
31
+
32
+ if (!ticketTags || ticketTags.length === 0) {
33
+ throw new ConfigurationError("At least one tag must be provided");
34
+ }
35
+
36
+ const response = await this.freshdesk.setTicketTags({
37
+ ticketId,
38
+ tags: ticketTags,
39
+ $,
40
+ });
41
+
42
+ $.export("$summary", `Successfully set ${ticketTags.length} tag(s) on ticket ${ticketId}`);
43
+ return response;
44
+ },
45
+ };
@@ -5,7 +5,7 @@ export default {
5
5
  key: "freshdesk-update-ticket",
6
6
  name: "Update a Ticket",
7
7
  description: "Update status, priority, subject, description, agent, group, etc. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
8
- version: "0.0.1",
8
+ version: "0.0.2",
9
9
  type: "action",
10
10
  props: {
11
11
  freshdesk,
package/freshdesk.app.mjs CHANGED
@@ -116,6 +116,12 @@ export default {
116
116
  }));
117
117
  },
118
118
  },
119
+ ticketTags: {
120
+ type: "string[]",
121
+ label: "Tags",
122
+ description: "Array of tags to apply to the ticket. Each tag must be 32 characters or less.",
123
+ optional: true,
124
+ },
119
125
  },
120
126
  methods: {
121
127
  setLastDateChecked(db, value) {
@@ -266,5 +272,78 @@ export default {
266
272
  }
267
273
  return input;
268
274
  },
275
+ /**
276
+ * Set tags on a ticket (replaces all existing tags)
277
+ * @param {object} args - Arguments object
278
+ * @param {string|number} args.ticketId - The ticket ID
279
+ * @param {string[]} args.tags - Array of tags to set
280
+ * @returns {Promise<object>} API response
281
+ */
282
+ async setTicketTags({
283
+ ticketId, tags, ...args
284
+ }) {
285
+ return this._makeRequest({
286
+ url: `/tickets/${ticketId}`,
287
+ method: "PUT",
288
+ data: {
289
+ tags,
290
+ },
291
+ ...args,
292
+ });
293
+ },
294
+ /**
295
+ * Add tags to a ticket (appends to existing tags)
296
+ * @param {object} args - Arguments object
297
+ * @param {string|number} args.ticketId - The ticket ID
298
+ * @param {string[]} args.tags - Array of tags to add
299
+ * @returns {Promise<object>} API response
300
+ */
301
+ async addTicketTags({
302
+ ticketId, tags, ...args
303
+ }) {
304
+ // Get current ticket to merge tags
305
+ const ticket = await this.getTicket({
306
+ ticketId,
307
+ ...args,
308
+ });
309
+ const currentTags = ticket.tags || [];
310
+ const newTags = [
311
+ ...new Set([
312
+ ...currentTags,
313
+ ...tags,
314
+ ]),
315
+ ]; // Remove duplicates
316
+
317
+ return this.setTicketTags({
318
+ ticketId,
319
+ tags: newTags,
320
+ ...args,
321
+ });
322
+ },
323
+ /**
324
+ * Remove specific tags from a ticket
325
+ * @param {object} args - Arguments object
326
+ * @param {string|number} args.ticketId - The ticket ID
327
+ * @param {string[]} args.tags - Array of tags to remove
328
+ * @returns {Promise<object>} API response
329
+ */
330
+ async removeTicketTags({
331
+ ticketId, tags, ...args
332
+ }) {
333
+ // Get current ticket to filter tags
334
+ const ticket = await this.getTicket({
335
+ ticketId,
336
+ ...args,
337
+ });
338
+ const currentTags = ticket.tags || [];
339
+ const tagsToRemove = new Set(tags);
340
+ const remainingTags = currentTags.filter((tag) => !tagsToRemove.has(tag));
341
+
342
+ return this.setTicketTags({
343
+ ticketId,
344
+ tags: remainingTags,
345
+ ...args,
346
+ });
347
+ },
269
348
  },
270
349
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/freshdesk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Pipedream Freshdesk Components",
5
5
  "main": "freshdesk.app.mjs",
6
6
  "keywords": [
@@ -6,7 +6,7 @@ export default {
6
6
  key: "freshdesk-new-contact",
7
7
  name: "New Contact Created",
8
8
  description: "Emit new event when a contact is created. [See the documentation](https://developers.freshdesk.com/api/#filter_contacts)",
9
- version: "0.0.5",
9
+ version: "0.0.6",
10
10
  type: "source",
11
11
  props: {
12
12
  freshdesk,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "freshdesk-new-ticket",
7
7
  name: "New Ticket Created",
8
8
  description: "Emit new event when a ticket is created. [See the documentation](https://developers.freshdesk.com/api/#filter_tickets)",
9
- version: "0.0.5",
9
+ version: "0.0.6",
10
10
  type: "source",
11
11
  props: {
12
12
  freshdesk,