@pipedream/zendesk 0.10.1 → 0.11.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.
Files changed (29) hide show
  1. package/actions/add-ticket-tags/add-ticket-tags.mjs +1 -1
  2. package/actions/create-ticket/create-ticket.mjs +1 -1
  3. package/actions/delete-ticket/delete-ticket.mjs +1 -1
  4. package/actions/get-article/get-article.mjs +43 -0
  5. package/actions/get-macro/get-macro.mjs +32 -0
  6. package/actions/get-ticket-info/get-ticket-info.mjs +1 -1
  7. package/actions/get-user-info/get-user-info.mjs +1 -1
  8. package/actions/list-active-macros/list-active-macros.mjs +77 -0
  9. package/actions/list-articles/list-articles.mjs +105 -0
  10. package/actions/list-locales/list-locales.mjs +1 -1
  11. package/actions/list-macros/list-macros.mjs +1 -1
  12. package/actions/list-ticket-comments/list-ticket-comments.mjs +1 -1
  13. package/actions/list-tickets/list-tickets.mjs +1 -1
  14. package/actions/remove-ticket-tags/remove-ticket-tags.mjs +1 -1
  15. package/actions/search-tickets/search-tickets.mjs +1 -1
  16. package/actions/set-custom-ticket-fields/set-custom-ticket-fields.mjs +3 -3
  17. package/actions/set-ticket-tags/set-ticket-tags.mjs +1 -1
  18. package/actions/update-ticket/update-ticket.mjs +1 -1
  19. package/common/constants.mjs +40 -0
  20. package/package.json +2 -2
  21. package/sources/locale-updated/locale-updated.mjs +1 -1
  22. package/sources/new-ticket/new-ticket.mjs +1 -1
  23. package/sources/new-ticket-comment-added/new-ticket-comment-added.mjs +1 -1
  24. package/sources/ticket-added-to-view/ticket-added-to-view.mjs +1 -1
  25. package/sources/ticket-closed/ticket-closed.mjs +1 -1
  26. package/sources/ticket-pended/ticket-pended.mjs +1 -1
  27. package/sources/ticket-solved/ticket-solved.mjs +1 -1
  28. package/sources/ticket-updated/ticket-updated.mjs +1 -1
  29. package/zendesk.app.mjs +212 -6
@@ -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.6",
8
+ version: "0.0.7",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -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.10",
8
+ version: "0.1.11",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -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.10",
8
+ version: "0.1.11",
9
9
  annotations: {
10
10
  destructiveHint: true,
11
11
  openWorldHint: true,
@@ -0,0 +1,43 @@
1
+ import zendesk from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-get-article",
5
+ name: "Get Article",
6
+ description: "Retrieves an article by its ID. [See the documentation](https://developer.zendesk.com/api-reference/help_center/help-center-api/articles/#show-article).",
7
+ type: "action",
8
+ version: "0.0.1",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ zendesk,
16
+ locale: {
17
+ propDefinition: [
18
+ zendesk,
19
+ "locale",
20
+ ],
21
+ optional: true,
22
+ },
23
+ articleId: {
24
+ propDefinition: [
25
+ zendesk,
26
+ "articleId",
27
+ ({ locale }) => ({
28
+ locale,
29
+ }),
30
+ ],
31
+ },
32
+ },
33
+ async run({ $ }) {
34
+ const article = await this.zendesk.getArticle({
35
+ $,
36
+ locale: this.locale,
37
+ articleId: this.articleId,
38
+ });
39
+
40
+ $.export("$summary", `Successfully retrieved article ${this.articleId}`);
41
+ return article;
42
+ },
43
+ };
@@ -0,0 +1,32 @@
1
+ import zendesk from "../../zendesk.app.mjs";
2
+
3
+ export default {
4
+ key: "zendesk-get-macro",
5
+ name: "Get Macro",
6
+ description: "Retrieves a macro by its ID. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#show-macro).",
7
+ type: "action",
8
+ version: "0.0.1",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ zendesk,
16
+ macroId: {
17
+ propDefinition: [
18
+ zendesk,
19
+ "macroId",
20
+ ],
21
+ },
22
+ },
23
+ async run({ $ }) {
24
+ const macro = await this.zendesk.getMacro({
25
+ $,
26
+ macroId: this.macroId,
27
+ });
28
+
29
+ $.export("$summary", `Successfully retrieved macro with ID ${this.macroId}`);
30
+ return macro;
31
+ },
32
+ };
@@ -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",
8
+ version: "0.0.9",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "zendesk-get-user-info",
5
5
  name: "Get User Info",
6
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.5",
7
+ version: "0.0.6",
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  openWorldHint: true,
@@ -0,0 +1,77 @@
1
+ import constants from "../../common/constants.mjs";
2
+ import zendesk from "../../zendesk.app.mjs";
3
+
4
+ export default {
5
+ key: "zendesk-list-active-macros",
6
+ name: "List Active Macros",
7
+ description: "Lists all active shared and personal macros available to the current user. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-active-macros).",
8
+ type: "action",
9
+ version: "0.0.1",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: true,
14
+ },
15
+ props: {
16
+ zendesk,
17
+ access: {
18
+ type: "string",
19
+ label: "Access",
20
+ description: "Filter macros by access. The \"agents\" value returns all personal macros for the account's agents and is only available to admins.",
21
+ options: constants.ACCESS_OPTIONS,
22
+ optional: true,
23
+ },
24
+ categoryId: {
25
+ propDefinition: [
26
+ zendesk,
27
+ "macroCategory",
28
+ ],
29
+ optional: true,
30
+ },
31
+ groupId: {
32
+ propDefinition: [
33
+ zendesk,
34
+ "groupId",
35
+ ],
36
+ optional: true,
37
+ },
38
+ include: {
39
+ type: "string",
40
+ label: "Include",
41
+ description: "Additional fields to include in the response",
42
+ options: constants.INCLUDE_OPTIONS,
43
+ optional: true,
44
+ },
45
+ sortBy: {
46
+ type: "string",
47
+ label: "Sort By",
48
+ description: "The field to sort the results by",
49
+ options: constants.SORT_BY_OPTIONS,
50
+ optional: true,
51
+ },
52
+ sortOrder: {
53
+ propDefinition: [
54
+ zendesk,
55
+ "sortOrder",
56
+ ],
57
+ },
58
+ },
59
+ async run({ $ }) {
60
+ const { macros } = await this.zendesk.listActiveMacros({
61
+ $,
62
+ params: {
63
+ access: this.access,
64
+ category: this.categoryId,
65
+ group_id: this.groupId,
66
+ include: this.include,
67
+ sort_by: this.sortBy,
68
+ sort_order: this.sortOrder,
69
+ },
70
+ });
71
+
72
+ $.export("$summary", `Successfully retrieved ${macros.length} macro${macros.length === 1
73
+ ? ""
74
+ : "s"}`);
75
+ return macros;
76
+ },
77
+ };
@@ -0,0 +1,105 @@
1
+ import { ConfigurationError } from "@pipedream/platform";
2
+ import zendesk from "../../zendesk.app.mjs";
3
+
4
+ export default {
5
+ key: "zendesk-list-articles",
6
+ name: "List Articles",
7
+ description: "Retrieves a list of articles. [See the documentation](https://developer.zendesk.com/api-reference/help_center/help-center-api/articles/#list-articles).",
8
+ type: "action",
9
+ version: "0.0.1",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: true,
14
+ },
15
+ props: {
16
+ zendesk,
17
+ locale: {
18
+ propDefinition: [
19
+ zendesk,
20
+ "locale",
21
+ ],
22
+ optional: true,
23
+ },
24
+ categoryId: {
25
+ propDefinition: [
26
+ zendesk,
27
+ "articleCategoryId",
28
+ ({ locale }) => ({
29
+ locale,
30
+ }),
31
+ ],
32
+ optional: true,
33
+ },
34
+ sectionId: {
35
+ propDefinition: [
36
+ zendesk,
37
+ "sectionId",
38
+ ({
39
+ locale, categoryId,
40
+ }) => ({
41
+ locale,
42
+ categoryId,
43
+ }),
44
+ ],
45
+ optional: true,
46
+ },
47
+ userId: {
48
+ propDefinition: [
49
+ zendesk,
50
+ "userId",
51
+ ],
52
+ optional: true,
53
+ reloadProps: true,
54
+ },
55
+ limit: {
56
+ propDefinition: [
57
+ zendesk,
58
+ "limit",
59
+ ],
60
+ description: "Maximum number of articles to return",
61
+ },
62
+ },
63
+ async additionalProps(props) {
64
+ props.locale.hidden = false;
65
+ props.categoryId.hidden = false;
66
+ props.sectionId.hidden = false;
67
+ if (this.userId) {
68
+ props.locale.hidden = true;
69
+ props.categoryId.hidden = true;
70
+ props.sectionId.hidden = true;
71
+ }
72
+ return {};
73
+ },
74
+ async run({ $ }) {
75
+ if ((this.categoryId && this.userId) || (this.sectionId && this.userId)) {
76
+ throw new ConfigurationError("Providing a User ID, you cannot provide a Category ID or Section ID.");
77
+ }
78
+
79
+ const results = this.zendesk.paginate({
80
+ fn: this.zendesk.listArticles,
81
+ args: {
82
+ $,
83
+ categoryId: this.categoryId,
84
+ sectionId: this.sectionId,
85
+ userId: this.userId,
86
+ locale: this.userId
87
+ ? null
88
+ : this.locale,
89
+ },
90
+ resourceKey: "articles",
91
+ max: this.limit,
92
+ });
93
+
94
+ const articles = [];
95
+ for await (const article of results) {
96
+ articles.push(article);
97
+ }
98
+
99
+ $.export("$summary", `Successfully retrieved ${articles.length} article${articles.length === 1
100
+ ? ""
101
+ : "s"}`);
102
+
103
+ return articles;
104
+ },
105
+ };
@@ -4,7 +4,7 @@ export default {
4
4
  key: "zendesk-list-locales",
5
5
  name: "List Locales",
6
6
  description: "Retrieves all locales. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/account-configuration/locales/).",
7
- version: "0.0.5",
7
+ version: "0.0.6",
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  openWorldHint: true,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "zendesk-list-macros",
5
5
  name: "List Macros",
6
6
  description: "Retrieves all macros. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macros).",
7
- version: "0.0.5",
7
+ version: "0.0.6",
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  openWorldHint: true,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "zendesk-list-ticket-comments",
5
5
  name: "List Ticket Comments",
6
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.5",
7
+ version: "0.0.6",
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  openWorldHint: true,
@@ -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",
8
+ version: "0.0.9",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -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.6",
8
+ version: "0.0.7",
9
9
  annotations: {
10
10
  destructiveHint: true,
11
11
  openWorldHint: true,
@@ -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.9",
8
+ version: "0.0.10",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -1,13 +1,13 @@
1
- import app from "../../zendesk.app.mjs";
2
- import { parseObject } from "../../common/utils.mjs";
3
1
  import { ConfigurationError } from "@pipedream/platform";
2
+ import { parseObject } from "../../common/utils.mjs";
3
+ import app from "../../zendesk.app.mjs";
4
4
 
5
5
  export default {
6
6
  key: "zendesk-set-custom-ticket-fields",
7
7
  name: "Set Custom Ticket Fields",
8
8
  description: "Sets one or more custom field values on a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).",
9
9
  type: "action",
10
- version: "0.0.3",
10
+ version: "0.0.4",
11
11
  annotations: {
12
12
  destructiveHint: false,
13
13
  openWorldHint: true,
@@ -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.6",
8
+ version: "0.0.7",
9
9
  annotations: {
10
10
  destructiveHint: true,
11
11
  openWorldHint: true,
@@ -5,7 +5,7 @@ export default {
5
5
  name: "Update Ticket",
6
6
  description: "Updates a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).",
7
7
  type: "action",
8
- version: "0.2.3",
8
+ version: "0.2.4",
9
9
  annotations: {
10
10
  destructiveHint: true,
11
11
  openWorldHint: true,
@@ -235,6 +235,44 @@ const SORT_BY_OPTIONS = [
235
235
  "updated_at",
236
236
  ];
237
237
 
238
+ const ACCESS_OPTIONS = [
239
+ "personal",
240
+ "agents",
241
+ "shared",
242
+ "account",
243
+ ];
244
+
245
+ const INCLUDE_OPTIONS = [
246
+ {
247
+ label: "The app installation that requires each macro, if present",
248
+ value: "app_installation",
249
+ },
250
+ {
251
+ label: "The macro categories",
252
+ value: "categories",
253
+ },
254
+ {
255
+ label: "The permissions for each macro",
256
+ value: "permissions",
257
+ },
258
+ {
259
+ label: "The number of times each macro has been used in the past hour",
260
+ value: "usage_1h",
261
+ },
262
+ {
263
+ label: "The number of times each macro has been used in the past day",
264
+ value: "usage_24h",
265
+ },
266
+ {
267
+ label: "The number of times each macro has been used in the past week",
268
+ value: "usage_7d",
269
+ },
270
+ {
271
+ label: "The number of times each macro has been used in the past thirty days",
272
+ value: "usage_30d",
273
+ },
274
+ ];
275
+
238
276
  export default {
239
277
  SUBDOMAIN_PLACEHOLDER,
240
278
  BASE_URL,
@@ -256,4 +294,6 @@ export default {
256
294
  TICKET_STATUS_OPTIONS,
257
295
  TICKET_FIELD_OPTIONS,
258
296
  SORT_BY_OPTIONS,
297
+ ACCESS_OPTIONS,
298
+ INCLUDE_OPTIONS,
259
299
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/zendesk",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Pipedream Zendesk Components",
5
5
  "main": "zendesk.app.mjs",
6
6
  "keywords": [
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@pipedream/platform": "^3.1.0",
17
+ "@pipedream/platform": "^3.1.1",
18
18
  "path": "^0.12.7"
19
19
  }
20
20
  }
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Locale Updated",
7
7
  type: "source",
8
8
  description: "Emit new event when a locale has been updated",
9
- version: "0.0.4",
9
+ version: "0.0.5",
10
10
  dedupe: "unique",
11
11
  async run() {
12
12
  const lastTs = this._getLastTs();
@@ -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.9",
9
+ version: "0.2.10",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...common.methods,
@@ -7,7 +7,7 @@ export default {
7
7
  key: "zendesk-new-ticket-comment-added",
8
8
  type: "source",
9
9
  description: "Emit new event when a ticket comment has been added",
10
- version: "0.1.1",
10
+ version: "0.1.2",
11
11
  dedupe: "unique",
12
12
  props: {
13
13
  app,
@@ -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.9",
8
+ version: "0.0.10",
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.9",
9
+ version: "0.2.10",
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.9",
9
+ version: "0.2.10",
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.9",
9
+ version: "0.2.10",
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.9",
9
+ version: "0.2.10",
10
10
  dedupe: "unique",
11
11
  methods: {
12
12
  ...common.methods,
package/zendesk.app.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import { axios } from "@pipedream/platform";
2
- import constants from "./common/constants.mjs";
3
- import { getFileStreamAndMetadata } from "@pipedream/platform";
1
+ import {
2
+ axios, getFileStreamAndMetadata,
3
+ } from "@pipedream/platform";
4
4
  import path from "path";
5
+ import constants from "./common/constants.mjs";
5
6
 
6
7
  export default {
7
8
  type: "app",
@@ -194,6 +195,134 @@ export default {
194
195
  return fields;
195
196
  },
196
197
  },
198
+ locale: {
199
+ type: "string",
200
+ label: "Locale",
201
+ description: "The locale of the article",
202
+ async options() {
203
+ const { locales } = await this.listLocales();
204
+ return locales.map((locale) => locale.locale);
205
+ },
206
+ },
207
+ articleCategoryId: {
208
+ type: "string",
209
+ label: "Article Category ID",
210
+ description: "The ID of the article category",
211
+ async options({
212
+ locale, prevContext,
213
+ }) {
214
+ const { afterCursor } = prevContext;
215
+ const {
216
+ categories, meta,
217
+ } = await this.listArticleCategories({
218
+ locale,
219
+ params: {
220
+ [constants.PAGE_SIZE_PARAM]: constants.DEFAULT_LIMIT,
221
+ [constants.PAGE_AFTER_PARAM]: afterCursor,
222
+ },
223
+ });
224
+ return {
225
+ context: {
226
+ afterCursor: meta.after_cursor,
227
+ },
228
+ options: categories.map(({
229
+ id: value, name: label,
230
+ }) => ({
231
+ value,
232
+ label,
233
+ })),
234
+ };
235
+ },
236
+ },
237
+ sectionId: {
238
+ type: "string",
239
+ label: "Section ID",
240
+ description: "The ID of the section",
241
+ async options({
242
+ locale, categoryId, prevContext,
243
+ }) {
244
+ const { afterCursor } = prevContext;
245
+ const {
246
+ sections, meta,
247
+ } = await this.listSections({
248
+ locale,
249
+ categoryId,
250
+ params: {
251
+ [constants.PAGE_SIZE_PARAM]: constants.DEFAULT_LIMIT,
252
+ [constants.PAGE_AFTER_PARAM]: afterCursor,
253
+ },
254
+ });
255
+ return {
256
+ context: {
257
+ afterCursor: meta.after_cursor,
258
+ },
259
+ options: sections.map(({
260
+ id: value, name: label,
261
+ }) => ({
262
+ value,
263
+ label,
264
+ })),
265
+ };
266
+ },
267
+ },
268
+ articleId: {
269
+ type: "string",
270
+ label: "Article ID",
271
+ description: "The ID of the article. You can use the List Articles action to get the ID of the article.",
272
+ async options({
273
+ locale, prevContext,
274
+ }) {
275
+ const { afterCursor } = prevContext;
276
+ const {
277
+ articles, meta,
278
+ } = await this.listArticles({
279
+ locale,
280
+ params: {
281
+ [constants.PAGE_SIZE_PARAM]: constants.DEFAULT_LIMIT,
282
+ [constants.PAGE_AFTER_PARAM]: afterCursor,
283
+ },
284
+ });
285
+ return {
286
+ context: {
287
+ afterCursor: meta.after_cursor,
288
+ },
289
+ options: articles.map(({
290
+ id: value, name: label,
291
+ }) => ({
292
+ value,
293
+ label,
294
+ })),
295
+ };
296
+ },
297
+ },
298
+ macroId: {
299
+ type: "string",
300
+ label: "Macro ID",
301
+ description: "The ID of the macro",
302
+ async options({ prevContext }) {
303
+ const { afterCursor } = prevContext;
304
+ const {
305
+ macros, meta,
306
+ } = await this.listMacros({
307
+ params: {
308
+ [constants.PAGE_SIZE_PARAM]: constants.DEFAULT_LIMIT,
309
+ [constants.PAGE_AFTER_PARAM]: afterCursor,
310
+ },
311
+ });
312
+
313
+ return {
314
+ context: {
315
+ afterCursor: meta.after_cursor,
316
+ },
317
+ options: macros.map(({
318
+ id: value, title: label,
319
+ }) => ({
320
+ value,
321
+ label,
322
+ })),
323
+ };
324
+ },
325
+ },
197
326
  ticketCommentBody: {
198
327
  type: "string",
199
328
  label: "Comment body",
@@ -336,13 +465,12 @@ export default {
336
465
  makeRequest({
337
466
  step = this, url, path, headers, customSubdomain, ...args
338
467
  }) {
339
- const config = {
468
+ return axios(step, {
340
469
  headers: this.getHeaders(headers),
341
470
  url: url ?? this.getUrl(path, customSubdomain),
342
471
  timeout: constants.DEFAULT_TIMEOUT,
343
472
  ...args,
344
- };
345
- return axios(step, config);
473
+ });
346
474
  },
347
475
  getTicketInfo({
348
476
  ticketId, ...args
@@ -530,6 +658,12 @@ export default {
530
658
  ...args,
531
659
  });
532
660
  },
661
+ listActiveMacros(args = {}) {
662
+ return this.makeRequest({
663
+ path: "/macros/active",
664
+ ...args,
665
+ });
666
+ },
533
667
  listMacroCategories(args = {}) {
534
668
  return this.makeRequest({
535
669
  path: "/macros/categories",
@@ -542,6 +676,78 @@ export default {
542
676
  ...args,
543
677
  });
544
678
  },
679
+ prepareLocalePath({
680
+ locale = null, path,
681
+ }) {
682
+ return `/help_center${locale
683
+ ? `/${locale}`
684
+ : ""}${path}`;
685
+ },
686
+ listArticleCategories({
687
+ locale, ...args
688
+ } = {}) {
689
+ return this.makeRequest({
690
+ path: this.prepareLocalePath({
691
+ locale,
692
+ path: "/categories",
693
+ }),
694
+ ...args,
695
+ });
696
+ },
697
+ listSections({
698
+ locale, categoryId, ...args
699
+ } = {}) {
700
+ return this.makeRequest({
701
+ path: this.prepareLocalePath({
702
+ locale,
703
+ path: `/${categoryId
704
+ ? `/categories/${categoryId}`
705
+ : ""}/sections`,
706
+ }),
707
+ ...args,
708
+ });
709
+ },
710
+ listArticles({
711
+ locale, categoryId, sectionId, userId, ...args
712
+ } = {}) {
713
+ let path = "";
714
+ if (categoryId) {
715
+ path = `/categories/${categoryId}`;
716
+ }
717
+ if (sectionId) {
718
+ path = `/sections/${sectionId}`;
719
+ }
720
+ if (userId) {
721
+ path = `/users/${userId}`;
722
+ }
723
+
724
+ return this.makeRequest({
725
+ path: this.prepareLocalePath({
726
+ locale,
727
+ path: `${path}/articles`,
728
+ }),
729
+ ...args,
730
+ });
731
+ },
732
+ getArticle({
733
+ articleId, locale, ...args
734
+ } = {}) {
735
+ return this.makeRequest({
736
+ path: this.prepareLocalePath({
737
+ locale,
738
+ path: `/articles/${articleId}`,
739
+ }),
740
+ ...args,
741
+ });
742
+ },
743
+ getMacro({
744
+ macroId, ...args
745
+ }) {
746
+ return this.makeRequest({
747
+ path: `/macros/${macroId}`,
748
+ ...args,
749
+ });
750
+ },
545
751
  async *paginate({
546
752
  fn, args, resourceKey, max,
547
753
  }) {