node-zendesk / Exports / clients/core/macros / Macros
Class: Macros
clients/core/macros.Macros
The Macros class provides methods for interacting with the Zendesk Macros API.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/ Zendesk Macros API
Hierarchy
↳
Macros
Table of contents
Constructors
Properties
Accessors
Methods
- _rawRequest
- apply
- applyTicket
- categories
- create
- delete
- emit
- get
- getAll
- list
- listActive
- listByParams
- on
- patch
- post
- put
- request
- requestAll
- requestUpload
- search
- setSideLoad
- show
- update
- updateMany
Constructors
constructor
• new Macros(options
): Macros
Parameters
Name | Type |
---|---|
options | any |
Returns
Overrides
Defined in
clients/core/macros.d.ts:6
Properties
_transporter
• _transporter: Transporter
Inherited from
Defined in
clients/client.d.ts:94
eventTarget
• eventTarget: CustomEventTarget
Event target to handle custom events.
Inherited from
Defined in
clients/client.d.ts:92
jsonAPINames
• jsonAPINames: string
[]
Array to hold names used in the JSON API.
Overrides
Defined in
clients/core/macros.d.ts:7
options
• options: ClientOptions
& { get
: (key
: string
) => any
}
Configuration options for the client.
Inherited from
Defined in
clients/client.d.ts:86
sideLoad
• sideLoad: any
[]
Array to handle side-loaded resources.
Inherited from
Defined in
clients/client.d.ts:89
useDotJson
• useDotJson: boolean
Flag to indicate if the API endpoint should use '.json' ending.
Inherited from
Defined in
clients/client.d.ts:91
Accessors
transporter
• get
transporter(): Transporter
Transporter for making requests.
Returns
Inherited from
Client.transporter
Defined in
clients/client.d.ts:93
Methods
_rawRequest
▸ _rawRequest(method
, uri
, ...args
): Promise
<{ response
: any
; result
: {} }>
Parameters
Name | Type |
---|---|
method | any |
uri | any |
...args | any [] |
Returns
Promise
<{ response
: any
; result
: {} }>
Inherited from
Defined in
clients/client.d.ts:130
apply
▸ apply(macroID
): Promise
<object
>
Applies a macro to a ticket.
Parameters
Name | Type | Description |
---|---|---|
macroID | number | The ID of the macro. |
Returns
Promise
<object
>
- A promise that resolves to the applied macro's result.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#show-macro-replica
Example
const result = await client.macros.apply(12345);
Defined in
clients/core/macros.d.ts:71
applyTicket
▸ applyTicket(ticketID
, macroID
): Promise
<object
>
Creates a macro representation derived from a ticket.
Parameters
Name | Type | Description |
---|---|---|
ticketID | number | The ID of the ticket from which to build a macro replica. |
macroID | number | The ID of the macro. |
Returns
Promise
<object
>
- A promise that resolves to the macro replica.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#show-macro-replica
Example
const replica = await client.macros.applyTicket(12345, 67890);
Defined in
clients/core/macros.d.ts:83
categories
▸ categories(): Promise
<object
>
Lists all macro categories available to the current user.
Returns
Promise
<object
>
- A promise that resolves to a list of macro categories.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macro-categories
Example
const macroCategories = await client.macros.categories();
Defined in
clients/core/macros.d.ts:116
create
▸ create(macro
): Promise
<object
>
Creates a new macro.
Parameters
Name | Type | Description |
---|---|---|
macro | Object | The macro object containing necessary values. |
macro.actions | object [] | List of actions that the macro will perform. |
macro.active? | boolean | Whether the macro is active. |
macro.description? | string | The description of the macro. |
macro.title | string | The title of the macro. |
Returns
Promise
<object
>
- A promise that resolves to the created macro.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#create-macro
Example
const newMacro = await client.macros.create({
title: "Test Macro",
actions: [{ field: "status", value: "solved" }]
});
Defined in
clients/core/macros.d.ts:101
delete
▸ delete(macroID
): Promise
<void
>
Deletes a specified macro.
Parameters
Name | Type | Description |
---|---|---|
macroID | number | The ID of the macro to delete. |
Returns
Promise
<void
>
- A promise indicating successful deletion.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#delete-macro
Example
await client.macros.delete(12345);
Overrides
Defined in
clients/core/macros.d.ts:141
emit
▸ emit(eventType
, eventData
): void
Parameters
Name | Type |
---|---|
eventType | any |
eventData | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:95
get
▸ get(resource
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:114
getAll
▸ getAll(resource
): Promise
<any
[]>
Parameters
Name | Type |
---|---|
resource | any |
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:129
list
▸ list(): Promise
<any
[]>
Lists all shared and personal macros available to the current user.
Returns
Promise
<any
[]>
Returns a promise that resolves to an array of macros.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macros Zendesk List Macros API
Example
const macros = await client.macros.list();
Defined in
clients/core/macros.d.ts:17
listActive
▸ listActive(): Promise
<object
[]>
Lists all active macros.
Returns
Promise
<object
[]>
- A promise that resolves to a list of active macros.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-active-macros
Example
const activeMacros = await client.macros.listActive();
Defined in
clients/core/macros.d.ts:49
listByParams
▸ listByParams(parameters
): Promise
<object
>
Lists macros based on provided parameters.
Parameters
Name | Type | Description |
---|---|---|
parameters | object | The filtering parameters. |
Returns
Promise
<object
>
- A promise that resolves to a list of macros.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macros
Example
const macros = await client.macros.listByParams({ active: true });
Defined in
clients/core/macros.d.ts:60
on
▸ on(eventType
, callback
): void
Parameters
Name | Type |
---|---|
eventType | any |
callback | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:96
patch
▸ patch(...args
): Promise
<void
| object
>
Patches a resource.
Parameters
Name | Type | Description |
---|---|---|
...args | any [] | The resources or parts of the resource path followed by the body. |
Returns
Promise
<void
| object
>
- Either void or response object
Inherited from
Defined in
clients/client.d.ts:120
post
▸ post(resource
, body
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
body | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:122
put
▸ put(resource
, body
): Promise
<NodeModule
>
Parameters
Name | Type |
---|---|
resource | any |
body | any |
Returns
Promise
<NodeModule
>
Inherited from
Defined in
clients/client.d.ts:121
request
▸ request<T
>(method
, uri
, ...args
): Promise
<NodeModule
>
Request method that handles various HTTP methods.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
method | string | HTTP method (e.g., 'GET', 'POST'). |
uri | string | The URI for the request. |
...args | any [] | Additional arguments for the request. |
Returns
Promise
<NodeModule
>
- The API response.
Inherited from
Defined in
clients/client.d.ts:148
requestAll
▸ requestAll(method
, uri
, ...args
): Promise
<any
[]>
Parameters
Name | Type |
---|---|
method | any |
uri | any |
...args | any [] |
Returns
Promise
<any
[]>
Inherited from
Defined in
clients/client.d.ts:149
requestUpload
▸ requestUpload(uri
, file
): Promise
<any
>
Parameters
Name | Type |
---|---|
uri | any |
file | any |
Returns
Promise
<any
>
Inherited from
Defined in
clients/client.d.ts:150
search
▸ search(query
): Promise
<object
[]>
Searches for macros based on provided query.
Parameters
Name | Type | Description |
---|---|---|
query | string | The search query string. |
Returns
Promise
<object
[]>
- A promise that resolves to a list of matched macros.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#search-macros
Example
const matchedMacros = await client.macros.search("priority:urgent");
Defined in
clients/core/macros.d.ts:39
setSideLoad
▸ setSideLoad(array
): void
Parameters
Name | Type |
---|---|
array | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:113
show
▸ show(macroID
): Promise
<object
>
Retrieves details of a specific macro.
Parameters
Name | Type | Description |
---|---|---|
macroID | number | The ID of the macro to retrieve. |
Returns
Promise
<object
>
Returns a promise that resolves to the macro's details.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#show-macro Zendesk Show Macro API
Example
const macroDetails = await client.macros.show(123);
Defined in
clients/core/macros.d.ts:28
update
▸ update(macroID
, macro
): Promise
<object
>
Updates an existing macro.
Parameters
Name | Type | Description |
---|---|---|
macroID | number | The ID of the macro to update. |
macro | object | The updates to apply to the macro. |
Returns
Promise
<object
>
- A promise that resolves to the updated macro.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#update-macro
Example
const updatedMacro = await client.macros.update(12345, {
title: "Updated Macro Title"
});
Defined in
clients/core/macros.d.ts:130
updateMany
▸ updateMany(macrosUpdates
): Promise
<object
[]>
Updates multiple macros.
Parameters
Name | Type | Description |
---|---|---|
macrosUpdates | object [] | An array of macro update objects. |
Returns
Promise
<object
[]>
- A promise that resolves to an array of updated macros.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#update-many-macros
Example
const updatedMacros = await client.macros.updateMany([
{ id: 12345, title: "Updated Macro One" },
{ id: 67890, title: "Updated Macro Two" }
]);
Defined in
clients/core/macros.d.ts:155