@pipedream/zendesk 0.7.2 → 0.8.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/actions/add-ticket-tags/add-ticket-tags.mjs +1 -1
- package/actions/create-ticket/create-ticket.mjs +1 -1
- package/actions/delete-ticket/delete-ticket.mjs +1 -1
- package/actions/get-ticket-info/get-ticket-info.mjs +1 -1
- package/actions/get-user-info/get-user-info.mjs +28 -0
- package/actions/list-locales/list-locales.mjs +21 -0
- package/actions/list-macros/list-macros.mjs +99 -0
- package/actions/list-ticket-comments/list-ticket-comments.mjs +56 -0
- package/actions/list-tickets/list-tickets.mjs +1 -1
- package/actions/remove-ticket-tags/remove-ticket-tags.mjs +1 -1
- package/actions/search-tickets/search-tickets.mjs +19 -20
- package/actions/set-ticket-tags/set-ticket-tags.mjs +1 -1
- package/actions/update-ticket/update-ticket.mjs +1 -1
- package/package.json +1 -1
- package/sources/common/polling.mjs +23 -0
- package/sources/common/webhook.mjs +10 -8
- package/sources/locale-updated/locale-updated.mjs +29 -0
- package/sources/new-ticket/new-ticket.mjs +1 -1
- package/sources/new-ticket-comment-added/new-ticket-comment-added.mjs +111 -0
- package/sources/ticket-added-to-view/ticket-added-to-view.mjs +1 -1
- package/sources/ticket-closed/ticket-closed.mjs +1 -1
- package/sources/ticket-pended/ticket-pended.mjs +1 -1
- package/sources/ticket-solved/ticket-solved.mjs +1 -1
- package/sources/ticket-updated/ticket-updated.mjs +1 -1
- package/zendesk.app.mjs +117 -0
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Add Ticket Tags",
|
|
6
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
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
ticketId: {
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
8
|
+
version: "0.0.4",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
sortBy: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Remove Ticket Tags",
|
|
6
6
|
description: "Remove specific tags from a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#remove-tags).",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
ticketId: {
|
|
@@ -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.
|
|
8
|
+
version: "0.0.5",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
query: {
|
|
@@ -37,6 +37,13 @@ export default {
|
|
|
37
37
|
"customSubdomain",
|
|
38
38
|
],
|
|
39
39
|
},
|
|
40
|
+
page: {
|
|
41
|
+
type: "integer",
|
|
42
|
+
label: "Page",
|
|
43
|
+
description: "The page number to retrieve. Default is 1.",
|
|
44
|
+
default: 1,
|
|
45
|
+
optional: true,
|
|
46
|
+
},
|
|
40
47
|
},
|
|
41
48
|
async run({ $: step }) {
|
|
42
49
|
const {
|
|
@@ -47,28 +54,20 @@ export default {
|
|
|
47
54
|
customSubdomain,
|
|
48
55
|
} = this;
|
|
49
56
|
|
|
50
|
-
const results = this.app.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
57
|
+
const results = await this.app.searchTickets({
|
|
58
|
+
step,
|
|
59
|
+
customSubdomain,
|
|
60
|
+
params: {
|
|
61
|
+
query,
|
|
62
|
+
sort_by: sortBy,
|
|
63
|
+
sort_order: sortOrder,
|
|
64
|
+
per_page: limit,
|
|
65
|
+
page: this.page,
|
|
60
66
|
},
|
|
61
|
-
resourceKey: "results",
|
|
62
|
-
max: limit,
|
|
63
67
|
});
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
for await (const ticket of results) {
|
|
67
|
-
tickets.push(ticket);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
step.export("$summary", `Successfully found ${tickets.length} tickets matching the search query`);
|
|
69
|
+
step.export("$summary", "Successfully retrieved tickets matching the search query");
|
|
71
70
|
|
|
72
|
-
return
|
|
71
|
+
return results;
|
|
73
72
|
},
|
|
74
73
|
};
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Set Ticket Tags",
|
|
6
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
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
ticketId: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Update Ticket",
|
|
6
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.
|
|
8
|
+
version: "0.1.6",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
ticketId: {
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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
|
+
};
|
|
@@ -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.
|
|
8
|
+
version: "0.0.6",
|
|
9
9
|
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
11
11
|
props: {
|
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",
|
|
@@ -234,6 +305,14 @@ export default {
|
|
|
234
305
|
...args,
|
|
235
306
|
});
|
|
236
307
|
},
|
|
308
|
+
getUserInfo({
|
|
309
|
+
userId, ...args
|
|
310
|
+
}) {
|
|
311
|
+
return this.makeRequest({
|
|
312
|
+
path: `/users/${userId}`,
|
|
313
|
+
...args,
|
|
314
|
+
});
|
|
315
|
+
},
|
|
237
316
|
searchTickets(args = {}) {
|
|
238
317
|
return this.makeRequest({
|
|
239
318
|
path: "/search",
|
|
@@ -290,6 +369,44 @@ export default {
|
|
|
290
369
|
...args,
|
|
291
370
|
});
|
|
292
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
|
+
},
|
|
293
410
|
async *paginate({
|
|
294
411
|
fn, args, resourceKey, max,
|
|
295
412
|
}) {
|