@pipedream/zendesk 0.4.0 → 0.6.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/actions/create-ticket/create-ticket.mjs +9 -1
- package/actions/delete-ticket/delete-ticket.mjs +14 -2
- package/actions/update-ticket/update-ticket.mjs +9 -1
- package/package.json +1 -1
- package/sources/common/webhook.mjs +24 -1
- package/sources/new-ticket/new-ticket.mjs +1 -1
- package/sources/ticket-added-to-view/ticket-added-to-view.mjs +50 -0
- package/sources/ticket-closed/ticket-closed.mjs +1 -1
- package/sources/ticket-pended/ticket-pended.mjs +4 -4
- package/sources/ticket-solved/ticket-solved.mjs +1 -1
- package/sources/ticket-updated/ticket-updated.mjs +1 -1
- package/zendesk.app.mjs +59 -5
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Create Ticket",
|
|
6
6
|
description: "Creates a ticket. [See the docs](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-ticket).",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.
|
|
8
|
+
version: "0.1.1",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
ticketCommentBody: {
|
|
@@ -32,6 +32,12 @@ export default {
|
|
|
32
32
|
"ticketStatus",
|
|
33
33
|
],
|
|
34
34
|
},
|
|
35
|
+
customSubdomain: {
|
|
36
|
+
propDefinition: [
|
|
37
|
+
app,
|
|
38
|
+
"customSubdomain",
|
|
39
|
+
],
|
|
40
|
+
},
|
|
35
41
|
},
|
|
36
42
|
methods: {
|
|
37
43
|
createTicket(args = {}) {
|
|
@@ -47,10 +53,12 @@ export default {
|
|
|
47
53
|
ticketPriority,
|
|
48
54
|
ticketSubject,
|
|
49
55
|
ticketStatus,
|
|
56
|
+
customSubdomain,
|
|
50
57
|
} = this;
|
|
51
58
|
|
|
52
59
|
const response = await this.createTicket({
|
|
53
60
|
step,
|
|
61
|
+
customSubdomain,
|
|
54
62
|
data: {
|
|
55
63
|
ticket: {
|
|
56
64
|
comment: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Delete Ticket",
|
|
6
6
|
description: "Deletes a ticket. [See the docs](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket).",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.
|
|
8
|
+
version: "0.1.1",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
ticketId: {
|
|
@@ -14,6 +14,12 @@ export default {
|
|
|
14
14
|
"ticketId",
|
|
15
15
|
],
|
|
16
16
|
},
|
|
17
|
+
customSubdomain: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
app,
|
|
20
|
+
"customSubdomain",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
17
23
|
},
|
|
18
24
|
methods: {
|
|
19
25
|
deleteTicket({
|
|
@@ -26,9 +32,15 @@ export default {
|
|
|
26
32
|
},
|
|
27
33
|
},
|
|
28
34
|
async run({ $: step }) {
|
|
35
|
+
const {
|
|
36
|
+
ticketId,
|
|
37
|
+
customSubdomain,
|
|
38
|
+
} = this;
|
|
39
|
+
|
|
29
40
|
await this.deleteTicket({
|
|
30
41
|
step,
|
|
31
|
-
ticketId
|
|
42
|
+
ticketId,
|
|
43
|
+
customSubdomain,
|
|
32
44
|
});
|
|
33
45
|
|
|
34
46
|
step.export("$summary", "Successfully deleted ticket");
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Update Ticket",
|
|
6
6
|
description: "Updates a ticket. [See the docs](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.
|
|
8
|
+
version: "0.1.1",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
ticketId: {
|
|
@@ -38,6 +38,12 @@ export default {
|
|
|
38
38
|
"ticketStatus",
|
|
39
39
|
],
|
|
40
40
|
},
|
|
41
|
+
customSubdomain: {
|
|
42
|
+
propDefinition: [
|
|
43
|
+
app,
|
|
44
|
+
"customSubdomain",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
41
47
|
},
|
|
42
48
|
methods: {
|
|
43
49
|
updateTicket({
|
|
@@ -56,11 +62,13 @@ export default {
|
|
|
56
62
|
ticketPriority,
|
|
57
63
|
ticketSubject,
|
|
58
64
|
ticketStatus,
|
|
65
|
+
customSubdomain,
|
|
59
66
|
} = this;
|
|
60
67
|
|
|
61
68
|
const response = await this.updateTicket({
|
|
62
69
|
step,
|
|
63
70
|
ticketId,
|
|
71
|
+
customSubdomain,
|
|
64
72
|
data: {
|
|
65
73
|
ticket: {
|
|
66
74
|
comment: {
|
package/package.json
CHANGED
|
@@ -13,12 +13,22 @@ export default {
|
|
|
13
13
|
"categoryId",
|
|
14
14
|
],
|
|
15
15
|
},
|
|
16
|
+
customSubdomain: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
app,
|
|
19
|
+
"customSubdomain",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
16
22
|
},
|
|
17
23
|
hooks: {
|
|
18
24
|
async activate() {
|
|
19
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
categoryId,
|
|
27
|
+
customSubdomain,
|
|
28
|
+
} = this;
|
|
20
29
|
|
|
21
30
|
const { webhook } = await this.createWebhook({
|
|
31
|
+
customSubdomain,
|
|
22
32
|
data: this.setupWebhookData(),
|
|
23
33
|
});
|
|
24
34
|
|
|
@@ -26,6 +36,7 @@ export default {
|
|
|
26
36
|
this.setWebhookId(webhookId);
|
|
27
37
|
|
|
28
38
|
const { signing_secret: signingSecret } = await this.showWebhookSigningSecret({
|
|
39
|
+
customSubdomain,
|
|
29
40
|
webhookId,
|
|
30
41
|
});
|
|
31
42
|
|
|
@@ -33,6 +44,7 @@ export default {
|
|
|
33
44
|
this.setSigningSecret(secret);
|
|
34
45
|
|
|
35
46
|
const { trigger } = await this.createTrigger({
|
|
47
|
+
customSubdomain,
|
|
36
48
|
data: this.setupTriggerData({
|
|
37
49
|
webhookId,
|
|
38
50
|
categoryId,
|
|
@@ -43,11 +55,14 @@ export default {
|
|
|
43
55
|
this.setTriggerId(String(triggerId));
|
|
44
56
|
},
|
|
45
57
|
async deactivate() {
|
|
58
|
+
const { customSubdomain } = this;
|
|
46
59
|
await Promise.all([
|
|
47
60
|
this.deleteTrigger({
|
|
61
|
+
customSubdomain,
|
|
48
62
|
triggerId: this.getTriggerId(),
|
|
49
63
|
}),
|
|
50
64
|
this.deleteWebhook({
|
|
65
|
+
customSubdomain,
|
|
51
66
|
webhookId: this.getWebhookId(),
|
|
52
67
|
}),
|
|
53
68
|
]);
|
|
@@ -182,6 +197,9 @@ export default {
|
|
|
182
197
|
) === 0
|
|
183
198
|
);
|
|
184
199
|
},
|
|
200
|
+
isRelevant() {
|
|
201
|
+
return true;
|
|
202
|
+
},
|
|
185
203
|
},
|
|
186
204
|
async run(event) {
|
|
187
205
|
const {
|
|
@@ -206,6 +224,11 @@ export default {
|
|
|
206
224
|
return;
|
|
207
225
|
}
|
|
208
226
|
|
|
227
|
+
const isRelevant = await this.isRelevant(payload);
|
|
228
|
+
if (!isRelevant) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
209
232
|
const ts = Date.parse(payload.updatedAt);
|
|
210
233
|
const id = `${payload.ticketId}-${ts}`;
|
|
211
234
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import common from "../common/ticket.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "zendesk-ticket-added-to-view",
|
|
6
|
+
name: "New Ticket Added to View (Instant)",
|
|
7
|
+
description: "Emit new event when a ticket is added to the specified view",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
props: {
|
|
12
|
+
...common.props,
|
|
13
|
+
viewId: {
|
|
14
|
+
propDefinition: [
|
|
15
|
+
common.props.app,
|
|
16
|
+
"viewId",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
methods: {
|
|
21
|
+
...common.methods,
|
|
22
|
+
getWebhookName() {
|
|
23
|
+
return "Ticket Added To View Webhook";
|
|
24
|
+
},
|
|
25
|
+
getTriggerTitle() {
|
|
26
|
+
return "Ticket Added To View Trigger";
|
|
27
|
+
},
|
|
28
|
+
getTriggerConditions() {
|
|
29
|
+
return {
|
|
30
|
+
any: [
|
|
31
|
+
{
|
|
32
|
+
field: "update_type",
|
|
33
|
+
value: "Change",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
field: "update_type",
|
|
37
|
+
value: "Create",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
async isRelevant(payload) {
|
|
43
|
+
const { tickets } = await this.app.listTicketsInView({
|
|
44
|
+
viewId: this.viewId,
|
|
45
|
+
});
|
|
46
|
+
const foundTicket = tickets.find(({ id }) => id == payload.ticketId);
|
|
47
|
+
return foundTicket;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -2,19 +2,19 @@ import common from "../common/ticket.mjs";
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
...common,
|
|
5
|
-
name: "Ticket
|
|
5
|
+
name: "Ticket Pending (Instant)",
|
|
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.1
|
|
9
|
+
version: "0.2.1",
|
|
10
10
|
dedupe: "unique",
|
|
11
11
|
methods: {
|
|
12
12
|
...common.methods,
|
|
13
13
|
getWebhookName() {
|
|
14
|
-
return "Ticket
|
|
14
|
+
return "Ticket Pending Webhook";
|
|
15
15
|
},
|
|
16
16
|
getTriggerTitle() {
|
|
17
|
-
return "Ticket
|
|
17
|
+
return "Ticket Pending Trigger";
|
|
18
18
|
},
|
|
19
19
|
getTriggerConditions() {
|
|
20
20
|
return {
|
package/zendesk.app.mjs
CHANGED
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
propDefinitions: {
|
|
8
8
|
categoryId: {
|
|
9
9
|
type: "string",
|
|
10
|
-
label: "Trigger
|
|
10
|
+
label: "Trigger Category ID",
|
|
11
11
|
description: "The ID of the trigger category. [See the docs here](https://developer.zendesk.com/api-reference/ticketing/business-rules/trigger_categories/#list-trigger-categories)",
|
|
12
12
|
async options({ prevContext }) {
|
|
13
13
|
const { afterCursor } = prevContext;
|
|
@@ -69,6 +69,37 @@ export default {
|
|
|
69
69
|
};
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
|
+
viewId: {
|
|
73
|
+
type: "string",
|
|
74
|
+
label: "View ID",
|
|
75
|
+
description: "The ID of the view",
|
|
76
|
+
async options({ prevContext }) {
|
|
77
|
+
const { afterCursor } = prevContext;
|
|
78
|
+
|
|
79
|
+
const {
|
|
80
|
+
views,
|
|
81
|
+
meta,
|
|
82
|
+
} =
|
|
83
|
+
await this.listViews({
|
|
84
|
+
params: {
|
|
85
|
+
[constants.PAGE_SIZE_PARAM]: constants.DEFAULT_LIMIT,
|
|
86
|
+
[constants.PAGE_AFTER_PARAM]: afterCursor,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
context: {
|
|
92
|
+
afterCursor: meta.after_cursor,
|
|
93
|
+
},
|
|
94
|
+
options: views.map(({
|
|
95
|
+
id, title,
|
|
96
|
+
}) => ({
|
|
97
|
+
label: title || `View #${id}`,
|
|
98
|
+
value: id,
|
|
99
|
+
})),
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
},
|
|
72
103
|
ticketCommentBody: {
|
|
73
104
|
type: "string",
|
|
74
105
|
label: "Comment body",
|
|
@@ -94,15 +125,24 @@ export default {
|
|
|
94
125
|
optional: true,
|
|
95
126
|
options: Object.values(constants.TICKET_STATUS_OPTIONS),
|
|
96
127
|
},
|
|
128
|
+
customSubdomain: {
|
|
129
|
+
type: "string",
|
|
130
|
+
label: "Custom Subdomain",
|
|
131
|
+
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`",
|
|
132
|
+
optional: true,
|
|
133
|
+
},
|
|
97
134
|
},
|
|
98
135
|
methods: {
|
|
99
|
-
getUrl(path) {
|
|
136
|
+
getUrl(path, customSubdomain) {
|
|
100
137
|
const {
|
|
101
138
|
SUBDOMAIN_PLACEHOLDER,
|
|
102
139
|
BASE_URL,
|
|
103
140
|
VERSION_PATH,
|
|
104
141
|
} = constants;
|
|
105
|
-
const baseUrl = BASE_URL.replace(
|
|
142
|
+
const baseUrl = BASE_URL.replace(
|
|
143
|
+
SUBDOMAIN_PLACEHOLDER,
|
|
144
|
+
customSubdomain?.trim() || this.$auth.subdomain,
|
|
145
|
+
);
|
|
106
146
|
return `${baseUrl}${VERSION_PATH}${path}`;
|
|
107
147
|
},
|
|
108
148
|
getHeaders(headers) {
|
|
@@ -112,11 +152,11 @@ export default {
|
|
|
112
152
|
};
|
|
113
153
|
},
|
|
114
154
|
makeRequest({
|
|
115
|
-
step = this, url, path, headers, ...args
|
|
155
|
+
step = this, url, path, headers, customSubdomain, ...args
|
|
116
156
|
}) {
|
|
117
157
|
const config = {
|
|
118
158
|
headers: this.getHeaders(headers),
|
|
119
|
-
url: url ?? this.getUrl(path),
|
|
159
|
+
url: url ?? this.getUrl(path, customSubdomain),
|
|
120
160
|
timeout: constants.DEFAULT_TIMEOUT,
|
|
121
161
|
...args,
|
|
122
162
|
};
|
|
@@ -152,5 +192,19 @@ export default {
|
|
|
152
192
|
...args,
|
|
153
193
|
});
|
|
154
194
|
},
|
|
195
|
+
listViews(args = {}) {
|
|
196
|
+
return this.makeRequest({
|
|
197
|
+
path: "/views",
|
|
198
|
+
...args,
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
listTicketsInView({
|
|
202
|
+
viewId, ...args
|
|
203
|
+
} = {}) {
|
|
204
|
+
return this.makeRequest({
|
|
205
|
+
path: `/views/${viewId}/tickets`,
|
|
206
|
+
...args,
|
|
207
|
+
});
|
|
208
|
+
},
|
|
155
209
|
},
|
|
156
210
|
};
|