Skip to content

node-zendesk / Exports / clients/core/policies / Policies

Class: Policies

clients/core/policies.Policies

Represents the SLA Policies functionality of Zendesk.

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/sla_policies/

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Policies(options): Policies

Constructs a new Policies instance.

Parameters

NameTypeDescription
optionsobjectOptions to configure the client.

Returns

Policies

Overrides

Client.constructor

Defined in

clients/core/policies.d.ts:10

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/policies.d.ts:11


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


create

create(policy): Promise<object>

Create a new SLA Policy.

Parameters

NameTypeDescription
policyobjectThe SLA Policy object to be created.

Returns

Promise<object>

  • A promise that resolves to the newly created policy details.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/sla_policies/#create-sla-policy

Example

ts
const newPolicy = {
  title: "Incidents",
  description: "For urgent incidents, we will respond to tickets in 10 minutes",
  //... other policy properties
};
const createdPolicy = await client.policies.create(newPolicy);

Defined in

clients/core/policies.d.ts:43


delete

delete(policyID): Promise<void>

Delete a specific SLA Policy.

Parameters

NameTypeDescription
policyIDnumberThe ID of the SLA Policy to be deleted.

Returns

Promise<void>

  • A promise that resolves when the policy has been deleted.

Async

Throws

Will throw an error if the deletion is unsuccessful.

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/sla_policies/#delete-sla-policy

Example

ts
await client.policies.delete(25);

Overrides

Client.delete

Defined in

clients/core/policies.d.ts:68


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


getDefinitions

getDefinitions(): Promise<object>

Retrieve a list of supported filter definition items.

Returns

Promise<object>

The response from the Zendesk API containing supported filter definitions.

Async

Throws

Throws an error if there's an issue with the request.

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/sla_policies/#retrieve-supported-filter-definition-items

Example

ts
const definitions = await client.policies.getDefinitions();

Defined in

clients/core/policies.d.ts:89


list

list(): Promise<object>

List all the SLA Policies.

Returns

Promise<object>

  • A promise that resolves to the list of policies.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/sla_policies/#list-sla-policies

Example

ts
const policiesList = await client.policies.list();

Defined in

clients/core/policies.d.ts:19


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


reorder

reorder(slaPolicyIds): Promise<object>

Reorder SLA Policies based on provided IDs.

Parameters

NameTypeDescription
slaPolicyIdsnumber[]Array of SLA policy IDs in the desired order.

Returns

Promise<object>

The response from the Zendesk API.

Async

Throws

Throws an error if there's an issue with the request.

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/sla_policies/#reorder-sla-policies

Example

ts
const reorderedResponse = await client.policies.reorder([55, 12]);

Defined in

clients/core/policies.d.ts:79


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


setSideLoad

setSideLoad(array): void

Parameters

NameType
arrayany

Returns

void

Inherited from

Client.setSideLoad

Defined in

clients/client.d.ts:113


show

show(policyID): Promise<object>

Show details of a specific SLA Policy.

Parameters

NameTypeDescription
policyIDnumberThe ID of the SLA Policy.

Returns

Promise<object>

  • A promise that resolves to the policy details.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/sla_policies/#show-sla-policy

Example

ts
const policyDetails = await client.policies.show(25);

Defined in

clients/core/policies.d.ts:28


update

update(policyID, policy): Promise<object>

Update an existing SLA Policy.

Parameters

NameTypeDescription
policyIDnumberThe ID of the SLA Policy to be updated.
policyobjectThe updated SLA Policy object.

Returns

Promise<object>

  • A promise that resolves to the updated policy details.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/sla_policies/#update-sla-policy

Example

ts
const updatedPolicy = {
  title: "Urgent Incidents",
  //... other updated policy properties
};
const result = await client.policies.update(25, updatedPolicy);

Defined in

clients/core/policies.d.ts:58

Released under the MIT License.