Skip to content

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

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Macros(options): Macros

Parameters

NameType
optionsany

Returns

Macros

Overrides

Client.constructor

Defined in

clients/core/macros.d.ts:6

Properties

_transporter

_transporter: Transporter

Inherited from

Client._transporter

Defined in

clients/client.d.ts:94


eventTarget

eventTarget: CustomEventTarget

Event target to handle custom events.

Inherited from

Client.eventTarget

Defined in

clients/client.d.ts:92


jsonAPINames

jsonAPINames: string[]

Array to hold names used in the JSON API.

Overrides

Client.jsonAPINames

Defined in

clients/core/macros.d.ts:7


options

options: ClientOptions & { get: (key: string) => any }

Configuration options for the client.

Inherited from

Client.options

Defined in

clients/client.d.ts:86


sideLoad

sideLoad: any[]

Array to handle side-loaded resources.

Inherited from

Client.sideLoad

Defined in

clients/client.d.ts:89


useDotJson

useDotJson: boolean

Flag to indicate if the API endpoint should use '.json' ending.

Inherited from

Client.useDotJson

Defined in

clients/client.d.ts:91

Accessors

transporter

get transporter(): Transporter

Transporter for making requests.

Returns

Transporter

Inherited from

Client.transporter

Defined in

clients/client.d.ts:93

Methods

_rawRequest

_rawRequest(method, uri, ...args): Promise<{ response: any ; result: {} }>

Parameters

NameType
methodany
uriany
...argsany[]

Returns

Promise<{ response: any ; result: {} }>

Inherited from

Client._rawRequest

Defined in

clients/client.d.ts:130


apply

apply(macroID): Promise<object>

Applies a macro to a ticket.

Parameters

NameTypeDescription
macroIDnumberThe 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

ts
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

NameTypeDescription
ticketIDnumberThe ID of the ticket from which to build a macro replica.
macroIDnumberThe 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

ts
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

ts
const macroCategories = await client.macros.categories();

Defined in

clients/core/macros.d.ts:116


create

create(macro): Promise<object>

Creates a new macro.

Parameters

NameTypeDescription
macroObjectThe macro object containing necessary values.
macro.actionsobject[]List of actions that the macro will perform.
macro.active?booleanWhether the macro is active.
macro.description?stringThe description of the macro.
macro.titlestringThe 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

ts
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

NameTypeDescription
macroIDnumberThe 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

ts
await client.macros.delete(12345);

Overrides

Client.delete

Defined in

clients/core/macros.d.ts:141


emit

emit(eventType, eventData): void

Parameters

NameType
eventTypeany
eventDataany

Returns

void

Inherited from

Client.emit

Defined in

clients/client.d.ts:95


get

get(resource): Promise<NodeModule>

Parameters

NameType
resourceany

Returns

Promise<NodeModule>

Inherited from

Client.get

Defined in

clients/client.d.ts:114


getAll

getAll(resource): Promise<any[]>

Parameters

NameType
resourceany

Returns

Promise<any[]>

Inherited from

Client.getAll

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

ts
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

ts
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

NameTypeDescription
parametersobjectThe 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

ts
const macros = await client.macros.listByParams({ active: true });

Defined in

clients/core/macros.d.ts:60


on

on(eventType, callback): void

Parameters

NameType
eventTypeany
callbackany

Returns

void

Inherited from

Client.on

Defined in

clients/client.d.ts:96


patch

patch(...args): Promise<void | object>

Patches a resource.

Parameters

NameTypeDescription
...argsany[]The resources or parts of the resource path followed by the body.

Returns

Promise<void | object>

  • Either void or response object

Inherited from

Client.patch

Defined in

clients/client.d.ts:120


post

post(resource, body): Promise<NodeModule>

Parameters

NameType
resourceany
bodyany

Returns

Promise<NodeModule>

Inherited from

Client.post

Defined in

clients/client.d.ts:122


put

put(resource, body): Promise<NodeModule>

Parameters

NameType
resourceany
bodyany

Returns

Promise<NodeModule>

Inherited from

Client.put

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

NameTypeDescription
methodstringHTTP method (e.g., 'GET', 'POST').
uristringThe URI for the request.
...argsany[]Additional arguments for the request.

Returns

Promise<NodeModule>

  • The API response.

Inherited from

Client.request

Defined in

clients/client.d.ts:148


requestAll

requestAll(method, uri, ...args): Promise<any[]>

Parameters

NameType
methodany
uriany
...argsany[]

Returns

Promise<any[]>

Inherited from

Client.requestAll

Defined in

clients/client.d.ts:149


requestUpload

requestUpload(uri, file): Promise<any>

Parameters

NameType
uriany
fileany

Returns

Promise<any>

Inherited from

Client.requestUpload

Defined in

clients/client.d.ts:150


search(query): Promise<object[]>

Searches for macros based on provided query.

Parameters

NameTypeDescription
querystringThe 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

ts
const matchedMacros = await client.macros.search("priority:urgent");

Defined in

clients/core/macros.d.ts:39


setSideLoad

setSideLoad(array): void

Parameters

NameType
arrayany

Returns

void

Inherited from

Client.setSideLoad

Defined in

clients/client.d.ts:113


show

show(macroID): Promise<object>

Retrieves details of a specific macro.

Parameters

NameTypeDescription
macroIDnumberThe 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

ts
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

NameTypeDescription
macroIDnumberThe ID of the macro to update.
macroobjectThe 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

ts
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

NameTypeDescription
macrosUpdatesobject[]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

ts
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

Released under the MIT License.