@pipedream/zendesk 0.7.1 → 0.8.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,48 @@
1
+ import app from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-add-ticket-tags",
5
+ name: "Add Ticket Tags",
6
+ description: "Add tags to a ticket (appends to existing tags). [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#add-tags).",
7
+ type: "action",
8
+ version: "0.0.2",
9
+ props: {
10
+ app,
11
+ ticketId: {
12
+ propDefinition: [
13
+ app,
14
+ "ticketId",
15
+ ],
16
+ },
17
+ ticketTags: {
18
+ propDefinition: [
19
+ app,
20
+ "ticketTags",
21
+ ],
22
+ description: "Array of tags to add to the ticket. These will be appended to any existing tags.",
23
+ },
24
+ customSubdomain: {
25
+ propDefinition: [
26
+ app,
27
+ "customSubdomain",
28
+ ],
29
+ },
30
+ },
31
+ async run({ $: step }) {
32
+ const {
33
+ ticketId,
34
+ ticketTags,
35
+ customSubdomain,
36
+ } = this;
37
+
38
+ const response = await this.app.addTicketTags({
39
+ step,
40
+ ticketId,
41
+ tags: ticketTags,
42
+ customSubdomain,
43
+ });
44
+
45
+ step.export("$summary", `Successfully added ${ticketTags.length} tag(s) to ticket ${ticketId}`);
46
+ return response;
47
+ },
48
+ };
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Create Ticket",
6
6
  description: "Creates a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-ticket).",
7
7
  type: "action",
8
- version: "0.1.4",
8
+ version: "0.1.6",
9
9
  props: {
10
10
  app,
11
11
  ticketCommentBody: {
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Delete Ticket",
6
6
  description: "Deletes a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket).",
7
7
  type: "action",
8
- version: "0.1.4",
8
+ version: "0.1.6",
9
9
  props: {
10
10
  app,
11
11
  ticketId: {
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Get Ticket Info",
6
6
  description: "Retrieves information about a specific ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-ticket).",
7
7
  type: "action",
8
- version: "0.0.2",
8
+ version: "0.0.4",
9
9
  props: {
10
10
  app,
11
11
  ticketId: {
@@ -0,0 +1,28 @@
1
+ import zendesk from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-get-user-info",
5
+ name: "Get User Info",
6
+ description: "Retrieves information about a specific user. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user).",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ zendesk,
11
+ userId: {
12
+ propDefinition: [
13
+ zendesk,
14
+ "userId",
15
+ ],
16
+ },
17
+ },
18
+ async run({ $: step }) {
19
+ const response = await this.zendesk.getUserInfo({
20
+ step,
21
+ userId: this.userId,
22
+ });
23
+
24
+ step.export("$summary", `Successfully retrieved user info for ${response.user.name}`);
25
+
26
+ return response;
27
+ },
28
+ };
@@ -0,0 +1,21 @@
1
+ import zendesk from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-list-locales",
5
+ name: "List Locales",
6
+ description: "Retrieves all locales. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/account-configuration/locales/).",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ zendesk,
11
+ },
12
+ async run({ $: step }) {
13
+ const { locales } = await this.zendesk.listLocales();
14
+
15
+ step.export("$summary", `Successfully retrieved ${locales.length} locale${locales.length === 1
16
+ ? ""
17
+ : "s"}`);
18
+
19
+ return locales;
20
+ },
21
+ };
@@ -0,0 +1,99 @@
1
+ import zendesk from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-list-macros",
5
+ name: "List Macros",
6
+ description: "Retrieves all macros. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macros).",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ zendesk,
11
+ access: {
12
+ type: "string",
13
+ label: "Access",
14
+ description: "The access level of the macros to return",
15
+ options: [
16
+ "personal",
17
+ "agents",
18
+ "shared",
19
+ "account",
20
+ ],
21
+ optional: true,
22
+ },
23
+ active: {
24
+ type: "boolean",
25
+ label: "Active",
26
+ description: "Filter by active macros if `true` or inactive macros if `false`",
27
+ optional: true,
28
+ },
29
+ macroCategory: {
30
+ propDefinition: [
31
+ zendesk,
32
+ "macroCategory",
33
+ ],
34
+ },
35
+ groupId: {
36
+ propDefinition: [
37
+ zendesk,
38
+ "groupId",
39
+ ],
40
+ },
41
+ sortBy: {
42
+ type: "string",
43
+ label: "Sort By",
44
+ description: "The field to sort the results by",
45
+ options: [
46
+ "alphabetical",
47
+ "created_at",
48
+ "updated_at",
49
+ "usage_1h",
50
+ "usage_24h",
51
+ "usage_7d",
52
+ "usage_30d",
53
+ ],
54
+ optional: true,
55
+ },
56
+ sortOrder: {
57
+ propDefinition: [
58
+ zendesk,
59
+ "sortOrder",
60
+ ],
61
+ },
62
+ limit: {
63
+ propDefinition: [
64
+ zendesk,
65
+ "limit",
66
+ ],
67
+ description: "Maximum number of macros to return",
68
+ },
69
+ },
70
+ async run({ $: step }) {
71
+ const results = this.zendesk.paginate({
72
+ fn: this.zendesk.listMacros,
73
+ args: {
74
+ step,
75
+ params: {
76
+ access: this.access,
77
+ active: this.active,
78
+ category: this.macroCategory,
79
+ group_id: this.groupId,
80
+ sort_by: this.sortBy,
81
+ sort_order: this.sortOrder,
82
+ },
83
+ },
84
+ resourceKey: "macros",
85
+ max: this.limit,
86
+ });
87
+
88
+ const macros = [];
89
+ for await (const macro of results) {
90
+ macros.push(macro);
91
+ }
92
+
93
+ step.export("$summary", `Successfully retrieved ${macros.length} macro${macros.length === 1
94
+ ? ""
95
+ : "s"}`);
96
+
97
+ return macros;
98
+ },
99
+ };
@@ -0,0 +1,56 @@
1
+ import zendesk from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-list-ticket-comments",
5
+ name: "List Ticket Comments",
6
+ description: "Retrieves all comments for a specific ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/#list-comments).",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ zendesk,
11
+ ticketId: {
12
+ propDefinition: [
13
+ zendesk,
14
+ "ticketId",
15
+ ],
16
+ },
17
+ sortOrder: {
18
+ propDefinition: [
19
+ zendesk,
20
+ "sortOrder",
21
+ ],
22
+ },
23
+ limit: {
24
+ propDefinition: [
25
+ zendesk,
26
+ "limit",
27
+ ],
28
+ description: "Maximum number of comments to return",
29
+ },
30
+ },
31
+ async run({ $: step }) {
32
+ const results = this.zendesk.paginate({
33
+ fn: this.zendesk.listTicketComments,
34
+ args: {
35
+ step,
36
+ ticketId: this.ticketId,
37
+ params: {
38
+ sort_order: this.sortOrder,
39
+ },
40
+ },
41
+ resourceKey: "comments",
42
+ max: this.limit,
43
+ });
44
+
45
+ const comments = [];
46
+ for await (const comment of results) {
47
+ comments.push(comment);
48
+ }
49
+
50
+ step.export("$summary", `Successfully retrieved ${comments.length} comment${comments.length === 1
51
+ ? ""
52
+ : "s"}`);
53
+
54
+ return comments;
55
+ },
56
+ };
@@ -5,7 +5,7 @@ export default {
5
5
  name: "List Tickets",
6
6
  description: "Retrieves a list of tickets. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets).",
7
7
  type: "action",
8
- version: "0.0.2",
8
+ version: "0.0.4",
9
9
  props: {
10
10
  app,
11
11
  sortBy: {
@@ -0,0 +1,48 @@
1
+ import app from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-remove-ticket-tags",
5
+ name: "Remove Ticket Tags",
6
+ description: "Remove specific tags from a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#remove-tags).",
7
+ type: "action",
8
+ version: "0.0.2",
9
+ props: {
10
+ app,
11
+ ticketId: {
12
+ propDefinition: [
13
+ app,
14
+ "ticketId",
15
+ ],
16
+ },
17
+ ticketTags: {
18
+ propDefinition: [
19
+ app,
20
+ "ticketTags",
21
+ ],
22
+ description: "Array of tags to remove from the ticket.",
23
+ },
24
+ customSubdomain: {
25
+ propDefinition: [
26
+ app,
27
+ "customSubdomain",
28
+ ],
29
+ },
30
+ },
31
+ async run({ $: step }) {
32
+ const {
33
+ ticketId,
34
+ ticketTags,
35
+ customSubdomain,
36
+ } = this;
37
+
38
+ const response = await this.app.removeTicketTags({
39
+ step,
40
+ ticketId,
41
+ tags: ticketTags,
42
+ customSubdomain,
43
+ });
44
+
45
+ step.export("$summary", `Successfully removed ${ticketTags.length} tag(s) from ticket ${ticketId}`);
46
+ return response;
47
+ },
48
+ };
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Search Tickets",
6
6
  description: "Searches for tickets using Zendesk's search API. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/#search-tickets).",
7
7
  type: "action",
8
- version: "0.0.2",
8
+ version: "0.0.4",
9
9
  props: {
10
10
  app,
11
11
  query: {
@@ -0,0 +1,47 @@
1
+ import app from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-set-ticket-tags",
5
+ name: "Set Ticket Tags",
6
+ description: "Set tags on a ticket (replaces all existing tags). [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#set-tags).",
7
+ type: "action",
8
+ version: "0.0.2",
9
+ props: {
10
+ app,
11
+ ticketId: {
12
+ propDefinition: [
13
+ app,
14
+ "ticketId",
15
+ ],
16
+ },
17
+ ticketTags: {
18
+ propDefinition: [
19
+ app,
20
+ "ticketTags",
21
+ ],
22
+ },
23
+ customSubdomain: {
24
+ propDefinition: [
25
+ app,
26
+ "customSubdomain",
27
+ ],
28
+ },
29
+ },
30
+ async run({ $: step }) {
31
+ const {
32
+ ticketId,
33
+ ticketTags,
34
+ customSubdomain,
35
+ } = this;
36
+
37
+ const response = await this.app.setTicketTags({
38
+ step,
39
+ ticketId,
40
+ tags: ticketTags,
41
+ customSubdomain,
42
+ });
43
+
44
+ step.export("$summary", `Successfully set ${ticketTags.length} tag(s) on ticket ${ticketId}`);
45
+ return response;
46
+ },
47
+ };
@@ -3,9 +3,9 @@ import app from "../../zendesk.app.mjs";
3
3
  export default {
4
4
  key: "zendesk-update-ticket",
5
5
  name: "Update Ticket",
6
- description: "Updates a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).",
6
+ description: "Updates a ticket and optionally manages tags. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).",
7
7
  type: "action",
8
- version: "0.1.4",
8
+ version: "0.1.6",
9
9
  props: {
10
10
  app,
11
11
  ticketId: {
@@ -56,6 +56,33 @@ export default {
56
56
  "customSubdomain",
57
57
  ],
58
58
  },
59
+ ticketTags: {
60
+ propDefinition: [
61
+ app,
62
+ "ticketTags",
63
+ ],
64
+ },
65
+ tagAction: {
66
+ type: "string",
67
+ label: "Tag Action",
68
+ description: "How to handle the tags: set (replace all existing tags), add (append to existing tags), or remove (remove specified tags)",
69
+ options: [
70
+ {
71
+ label: "Set Tags (Replace All)",
72
+ value: "set",
73
+ },
74
+ {
75
+ label: "Add Tags (Append)",
76
+ value: "add",
77
+ },
78
+ {
79
+ label: "Remove Tags",
80
+ value: "remove",
81
+ },
82
+ ],
83
+ optional: true,
84
+ default: "set",
85
+ },
59
86
  },
60
87
  methods: {
61
88
  updateTicket({
@@ -77,6 +104,8 @@ export default {
77
104
  ticketStatus,
78
105
  ticketCommentPublic,
79
106
  customSubdomain,
107
+ ticketTags,
108
+ tagAction,
80
109
  } = this;
81
110
 
82
111
  const ticketComment = ticketCommentBodyIsHTML
@@ -103,8 +132,54 @@ export default {
103
132
  },
104
133
  });
105
134
 
106
- step.export("$summary", `Successfully updated ticket with ID ${response.ticket.id}`);
135
+ // Handle tag operations if tags are provided
136
+ if (ticketTags && ticketTags.length > 0) {
137
+ let tagResponse;
138
+
139
+ switch (tagAction) {
140
+ case "add":
141
+ tagResponse = await this.app.addTicketTags({
142
+ step,
143
+ ticketId,
144
+ tags: ticketTags,
145
+ customSubdomain,
146
+ });
147
+ break;
148
+ case "remove":
149
+ tagResponse = await this.app.removeTicketTags({
150
+ step,
151
+ ticketId,
152
+ tags: ticketTags,
153
+ customSubdomain,
154
+ });
155
+ break;
156
+ case "set":
157
+ default:
158
+ tagResponse = await this.app.setTicketTags({
159
+ step,
160
+ ticketId,
161
+ tags: ticketTags,
162
+ customSubdomain,
163
+ });
164
+ break;
165
+ }
107
166
 
167
+ // Include tag information in summary
168
+ const tagSummary = `and ${tagAction === "set"
169
+ ? "set"
170
+ : tagAction === "add"
171
+ ? "added"
172
+ : "removed"} ${ticketTags.length} tag(s)`;
173
+ step.export("$summary", `Successfully updated ticket with ID ${response.ticket.id} ${tagSummary}`);
174
+ // Include tag response in the return data
175
+ return {
176
+ ticket: response,
177
+ tags: tagResponse,
178
+ };
179
+ }
180
+
181
+ step.export("$summary", `Successfully updated ticket with ID ${response.ticket.id}`);
108
182
  return response;
109
183
  },
110
184
  };
185
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/zendesk",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Pipedream Zendesk Components",
5
5
  "main": "zendesk.app.mjs",
6
6
  "keywords": [
@@ -0,0 +1,23 @@
1
+ import zendesk from "../../zendesk.app.mjs";
2
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3
+
4
+ export default {
5
+ props: {
6
+ zendesk,
7
+ db: "$.service.db",
8
+ timer: {
9
+ type: "$.interface.timer",
10
+ default: {
11
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
12
+ },
13
+ },
14
+ },
15
+ methods: {
16
+ _getLastTs() {
17
+ return this.db.get("lastTs") || 0;
18
+ },
19
+ _setLastTs(ts) {
20
+ this.db.set("lastTs", ts);
21
+ },
22
+ },
23
+ };
@@ -212,6 +212,15 @@ export default {
212
212
  isRelevant() {
213
213
  return true;
214
214
  },
215
+ emitEvent(payload) {
216
+ const ts = Date.parse(payload.updatedAt);
217
+ const id = `${payload.ticketId}-${ts}`;
218
+ this.$emit(payload, {
219
+ id,
220
+ summary: payload.title || payload.ticketId,
221
+ ts,
222
+ });
223
+ },
215
224
  },
216
225
  async run(event) {
217
226
  const {
@@ -241,13 +250,6 @@ export default {
241
250
  return;
242
251
  }
243
252
 
244
- const ts = Date.parse(payload.updatedAt);
245
- const id = `${payload.ticketId}-${ts}`;
246
-
247
- this.$emit(payload, {
248
- id,
249
- summary: payload.title || payload.ticketId,
250
- ts,
251
- });
253
+ this.emitEvent(payload);
252
254
  },
253
255
  };
@@ -0,0 +1,29 @@
1
+ import common from "../common/polling.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "zendesk-locale-updated",
6
+ name: "Locale Updated",
7
+ type: "source",
8
+ description: "Emit new event when a locale has been updated",
9
+ version: "0.0.1",
10
+ dedupe: "unique",
11
+ async run() {
12
+ const lastTs = this._getLastTs();
13
+ let maxTs = lastTs;
14
+
15
+ const { locales } = await this.zendesk.listLocales();
16
+ for (const locale of locales) {
17
+ const ts = Date.parse(locale.updated_at);
18
+ if (ts > lastTs) {
19
+ this.$emit(locale, {
20
+ id: `${locale.id}-${ts}`,
21
+ summary: locale.name,
22
+ ts,
23
+ });
24
+ maxTs = Math.max(maxTs, ts);
25
+ }
26
+ }
27
+ this._setLastTs(maxTs);
28
+ },
29
+ };
@@ -6,7 +6,7 @@ export default {
6
6
  key: "zendesk-new-ticket",
7
7
  type: "source",
8
8
  description: "Emit new event when a ticket is created",
9
- version: "0.2.4",
9
+ version: "0.2.6",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...common.methods,
@@ -0,0 +1,111 @@
1
+ import app from "../../zendesk.app.mjs";
2
+ import common from "../common/ticket.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ name: "New Ticket Comment Added (Instant)",
7
+ key: "zendesk-new-ticket-comment-added",
8
+ type: "source",
9
+ description: "Emit new event when a ticket comment has been added",
10
+ version: "0.0.1",
11
+ dedupe: "unique",
12
+ props: {
13
+ app,
14
+ db: "$.service.db",
15
+ http: "$.interface.http",
16
+ categoryId: {
17
+ propDefinition: [
18
+ app,
19
+ "categoryId",
20
+ ],
21
+ },
22
+ customSubdomain: {
23
+ propDefinition: [
24
+ app,
25
+ "customSubdomain",
26
+ ],
27
+ },
28
+ },
29
+ methods: {
30
+ ...common.methods,
31
+ _getLastTs() {
32
+ return this.db.get("lastTs");
33
+ },
34
+ _setLastTs(ts) {
35
+ this.db.set("lastTs", ts);
36
+ },
37
+ getWebhookName() {
38
+ return "Ticket Comment Added Webhook";
39
+ },
40
+ getTriggerTitle() {
41
+ return "Ticket Comment Added Trigger";
42
+ },
43
+ getTriggerConditions() {
44
+ return {
45
+ all: [
46
+ {
47
+ field: "update_type",
48
+ value: "Change",
49
+ },
50
+ ],
51
+ };
52
+ },
53
+ getTriggerPayload() {
54
+ const payload = common.methods.getTriggerPayload.call(this);
55
+ return {
56
+ ...payload,
57
+ ticketComments: "{{ticket.comments}}",
58
+ };
59
+ },
60
+ convertCommentsToJson(raw) {
61
+ return [
62
+ ...raw.matchAll(/#<Comment (.*?)>/g),
63
+ ].map((match) => {
64
+ const fields = match[1]
65
+ .split(",")
66
+ .map((part) => part.trim())
67
+ .map((pair) => {
68
+ const [
69
+ key,
70
+ value,
71
+ ] = pair.split(/:\s+/);
72
+ // Clean up values: remove extra quotes or cast to appropriate types
73
+ let cleaned = value;
74
+ if (cleaned === "nil") cleaned = null;
75
+ else if (cleaned === "true") cleaned = true;
76
+ else if (cleaned === "false") cleaned = false;
77
+ else if (/^\d+$/.test(cleaned)) cleaned = parseInt(cleaned, 10);
78
+ else if (/^".*"$/.test(cleaned)) cleaned = cleaned.slice(1, -1);
79
+ return [
80
+ key,
81
+ cleaned,
82
+ ];
83
+ });
84
+ return Object.fromEntries(fields);
85
+ });
86
+ },
87
+ isRelevant(payload) {
88
+ const lastTs = this._getLastTs() || 0;
89
+ let maxTs = lastTs;
90
+ const comments = this.convertCommentsToJson(payload.ticketComments);
91
+ for (const comment of comments) {
92
+ const ts = Date.parse(comment.created_at);
93
+ maxTs = Math.max(maxTs, ts);
94
+ }
95
+ this._setLastTs(maxTs);
96
+ return comments.length > 0 && maxTs > lastTs;
97
+ },
98
+ emitEvent(payload) {
99
+ payload.ticketComments = this.convertCommentsToJson(payload.ticketComments);
100
+ for (const comment of payload.ticketComments) {
101
+ const ts = Date.parse(comment.created_at);
102
+ const id = `${payload.ticketId}-${ts}`;
103
+ this.$emit(comment, {
104
+ id,
105
+ summary: comment.value,
106
+ ts,
107
+ });
108
+ }
109
+ },
110
+ },
111
+ };
@@ -5,7 +5,7 @@ export default {
5
5
  key: "zendesk-ticket-added-to-view",
6
6
  name: "New Ticket Added to View (Instant)",
7
7
  description: "Emit new event when a ticket is added to the specified view",
8
- version: "0.0.4",
8
+ version: "0.0.6",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -6,7 +6,7 @@ export default {
6
6
  key: "zendesk-ticket-closed",
7
7
  type: "source",
8
8
  description: "Emit new event when a ticket has changed to closed status",
9
- version: "0.2.4",
9
+ version: "0.2.6",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...common.methods,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "zendesk-ticket-pended",
7
7
  type: "source",
8
8
  description: "Emit new event when a ticket has changed to pending status",
9
- version: "0.2.4",
9
+ version: "0.2.6",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...common.methods,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "zendesk-ticket-solved",
7
7
  type: "source",
8
8
  description: "Emit new event when a ticket has changed to solved status",
9
- version: "0.2.4",
9
+ version: "0.2.6",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...common.methods,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "zendesk-ticket-updated",
7
7
  type: "source",
8
8
  description: "Emit new event when a ticket has been updated",
9
- version: "0.2.4",
9
+ version: "0.2.6",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...common.methods,
package/zendesk.app.mjs CHANGED
@@ -101,6 +101,77 @@ export default {
101
101
  };
102
102
  },
103
103
  },
104
+ userId: {
105
+ type: "string",
106
+ label: "User ID",
107
+ description: "The ID of the user",
108
+ async options({ prevContext }) {
109
+ const { afterCursor } = prevContext;
110
+
111
+ const {
112
+ users,
113
+ meta,
114
+ } = await this.listUsers({
115
+ params: {
116
+ [constants.PAGE_SIZE_PARAM]: constants.DEFAULT_LIMIT,
117
+ [constants.PAGE_AFTER_PARAM]: afterCursor,
118
+ },
119
+ });
120
+
121
+ return {
122
+ context: {
123
+ afterCursor: meta.after_cursor,
124
+ },
125
+ options: users.map(({
126
+ id, name,
127
+ }) => ({
128
+ label: name,
129
+ value: id,
130
+ })),
131
+ };
132
+ },
133
+ },
134
+ groupId: {
135
+ type: "string",
136
+ label: "Group ID",
137
+ description: "The ID of the group",
138
+ optional: true,
139
+ async options({ prevContext }) {
140
+ const { afterCursor } = prevContext;
141
+
142
+ const {
143
+ groups,
144
+ meta,
145
+ } = await this.listGroups({
146
+ params: {
147
+ [constants.PAGE_SIZE_PARAM]: constants.DEFAULT_LIMIT,
148
+ [constants.PAGE_AFTER_PARAM]: afterCursor,
149
+ },
150
+ });
151
+
152
+ return {
153
+ context: {
154
+ afterCursor: meta.after_cursor,
155
+ },
156
+ options: groups.map(({
157
+ id, name,
158
+ }) => ({
159
+ label: name,
160
+ value: id,
161
+ })),
162
+ };
163
+ },
164
+ },
165
+ macroCategory: {
166
+ type: "string",
167
+ label: "Macro Category",
168
+ description: "The category of the macro",
169
+ optional: true,
170
+ async options() {
171
+ const { categories } = await this.listMacroCategories();
172
+ return categories.map((category) => category);
173
+ },
174
+ },
104
175
  fields: {
105
176
  type: "string[]",
106
177
  label: "Fields",
@@ -189,6 +260,12 @@ export default {
189
260
  description: "For Enterprise Zendesk accounts: optionally specify the subdomain to use. This will override the subdomain that was provided when connecting your Zendesk account to Pipedream. For example, if you Zendesk URL is https://examplehelp.zendesk.com, your subdomain is `examplehelp`",
190
261
  optional: true,
191
262
  },
263
+ ticketTags: {
264
+ type: "string[]",
265
+ label: "Tags",
266
+ description: "Array of tags to apply to the ticket. These will replace any existing tags on the ticket.",
267
+ optional: true,
268
+ },
192
269
  },
193
270
  methods: {
194
271
  getUrl(path, customSubdomain) {
@@ -228,6 +305,14 @@ export default {
228
305
  ...args,
229
306
  });
230
307
  },
308
+ getUserInfo({
309
+ userId, ...args
310
+ }) {
311
+ return this.makeRequest({
312
+ path: `/users/${userId}`,
313
+ ...args,
314
+ });
315
+ },
231
316
  searchTickets(args = {}) {
232
317
  return this.makeRequest({
233
318
  path: "/search",
@@ -284,6 +369,44 @@ export default {
284
369
  ...args,
285
370
  });
286
371
  },
372
+ listTicketComments({
373
+ ticketId, ...args
374
+ } = {}) {
375
+ return this.makeRequest({
376
+ path: `/tickets/${ticketId}/comments`,
377
+ ...args,
378
+ });
379
+ },
380
+ listUsers(args = {}) {
381
+ return this.makeRequest({
382
+ path: "/users",
383
+ ...args,
384
+ });
385
+ },
386
+ listLocales(args = {}) {
387
+ return this.makeRequest({
388
+ path: "/locales",
389
+ ...args,
390
+ });
391
+ },
392
+ listMacros(args = {}) {
393
+ return this.makeRequest({
394
+ path: "/macros",
395
+ ...args,
396
+ });
397
+ },
398
+ listMacroCategories(args = {}) {
399
+ return this.makeRequest({
400
+ path: "/macros/categories",
401
+ ...args,
402
+ });
403
+ },
404
+ listGroups(args = {}) {
405
+ return this.makeRequest({
406
+ path: "/groups",
407
+ ...args,
408
+ });
409
+ },
287
410
  async *paginate({
288
411
  fn, args, resourceKey, max,
289
412
  }) {
@@ -315,5 +438,68 @@ export default {
315
438
  args.params.page += 1;
316
439
  }
317
440
  },
441
+ /**
442
+ * Set tags on a ticket (replaces all existing tags)
443
+ * @param {object} args - Arguments object
444
+ * @param {string} args.ticketId - The ticket ID
445
+ * @param {string[]} args.tags - Array of tags to set
446
+ * @param {string} args.customSubdomain - Optional custom subdomain
447
+ * @returns {Promise<object>} API response
448
+ */
449
+ setTicketTags({
450
+ ticketId, tags, customSubdomain, ...args
451
+ }) {
452
+ return this.makeRequest({
453
+ method: "POST",
454
+ path: `/tickets/${ticketId}/tags.json`,
455
+ customSubdomain,
456
+ data: {
457
+ tags,
458
+ },
459
+ ...args,
460
+ });
461
+ },
462
+ /**
463
+ * Add tags to a ticket (appends to existing tags)
464
+ * @param {object} args - Arguments object
465
+ * @param {string} args.ticketId - The ticket ID
466
+ * @param {string[]} args.tags - Array of tags to add
467
+ * @param {string} args.customSubdomain - Optional custom subdomain
468
+ * @returns {Promise<object>} API response
469
+ */
470
+ addTicketTags({
471
+ ticketId, tags, customSubdomain, ...args
472
+ }) {
473
+ return this.makeRequest({
474
+ method: "PUT",
475
+ path: `/tickets/${ticketId}/tags.json`,
476
+ customSubdomain,
477
+ data: {
478
+ tags,
479
+ },
480
+ ...args,
481
+ });
482
+ },
483
+ /**
484
+ * Remove specific tags from a ticket
485
+ * @param {object} args - Arguments object
486
+ * @param {string} args.ticketId - The ticket ID
487
+ * @param {string[]} args.tags - Array of tags to remove
488
+ * @param {string} args.customSubdomain - Optional custom subdomain
489
+ * @returns {Promise<object>} API response
490
+ */
491
+ removeTicketTags({
492
+ ticketId, tags, customSubdomain, ...args
493
+ }) {
494
+ return this.makeRequest({
495
+ method: "DELETE",
496
+ path: `/tickets/${ticketId}/tags.json`,
497
+ customSubdomain,
498
+ data: {
499
+ tags,
500
+ },
501
+ ...args,
502
+ });
503
+ },
318
504
  },
319
505
  };