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
↳
Policies
Table of contents
Constructors
Properties
Accessors
Methods
- _rawRequest
- create
- delete
- emit
- get
- getAll
- getDefinitions
- list
- on
- patch
- post
- put
- reorder
- request
- requestAll
- requestUpload
- setSideLoad
- show
- update
Constructors
constructor
• new Policies(options
): Policies
Constructs a new Policies instance.
Parameters
Name | Type | Description |
---|---|---|
options | object | Options to configure the client. |
Returns
Overrides
Defined in
clients/core/policies.d.ts:10
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/policies.d.ts:11
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
create
▸ create(policy
): Promise
<object
>
Create a new SLA Policy.
Parameters
Name | Type | Description |
---|---|---|
policy | object | The 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
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
Name | Type | Description |
---|---|---|
policyID | number | The 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
await client.policies.delete(25);
Overrides
Defined in
clients/core/policies.d.ts:68
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
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
Example
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
const policiesList = await client.policies.list();
Defined in
clients/core/policies.d.ts:19
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
reorder
▸ reorder(slaPolicyIds
): Promise
<object
>
Reorder SLA Policies based on provided IDs.
Parameters
Name | Type | Description |
---|---|---|
slaPolicyIds | number [] | 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
Example
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
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
setSideLoad
▸ setSideLoad(array
): void
Parameters
Name | Type |
---|---|
array | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:113
show
▸ show(policyID
): Promise
<object
>
Show details of a specific SLA Policy.
Parameters
Name | Type | Description |
---|---|---|
policyID | number | The 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
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
Name | Type | Description |
---|---|---|
policyID | number | The ID of the SLA Policy to be updated. |
policy | object | The 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
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