Skip to content

node-zendesk / Exports / clients/core/requests / Requests

Class: Requests

clients/core/requests.Requests

Represents a client to interact with the Zendesk API, providing functionalities to make various types of requests. This client handles request construction, response processing, event emission, and more.

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Requests(options): Requests

Parameters

NameType
optionsany

Returns

Requests

Overrides

Client.constructor

Defined in

clients/core/requests.d.ts:2

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/requests.d.ts:3


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


sideLoadMap

sideLoadMap: { dataset: string ; field: string ; name: string }[]

Defined in

clients/core/requests.d.ts:4


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(requestDetails): Promise<object>

Create a new ticket request.

Parameters

NameTypeDescription
requestDetailsobjectDetails of the ticket request to be created.

Returns

Promise<object>

The created ticket request details.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#create-request

Example

ts
const newRequest = {
  subject: 'Help!',
  comment: {
    body: 'My printer is on fire!'
  }
};
const createdRequest = await client.requests.create(newRequest);

Defined in

clients/core/requests.d.ts:151


delete

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

Deletes a resource.

Parameters

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

Returns

Promise<void | object>

  • Either void or response object

Inherited from

Client.delete

Defined in

clients/client.d.ts:128


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


getComment

getComment(requestId, commentId): Promise<object>

Retrieve a specific comment from a ticket request.

Parameters

NameTypeDescription
requestIdnumberThe ID of the ticket request.
commentIdnumberThe ID of the comment to retrieve.

Returns

Promise<object>

The comment details for the specified ticket request.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#listing-comments

Example

ts
const comment = await client.requests.getComment(1234, 5678);

Defined in

clients/core/requests.d.ts:189


getRequest

getRequest(requestId): Promise<object>

Retrieve a specific ticket request.

Parameters

NameTypeDescription
requestIdnumberThe ID of the ticket request.

Returns

Promise<object>

The ticket request details.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#show-request

Example

ts
const requestDetails = await client.requests.show(1234);

Deprecated

Use show instead

Defined in

clients/core/requests.d.ts:134


list

list(parameters?): Promise<object[]>

List all ticket requests.

Parameters

NameTypeDescription
parameters?ObjectOptional parameters.
parameters.sort_by?stringSort by "updated_at" or "created_at".
parameters.sort_order?stringSort order: "asc" or "desc".

Returns

Promise<object[]>

List of ticket requests.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests

Example

ts
const requests = await client.requests.list({ sort_by: 'updated_at', sort_order: 'desc' });

Defined in

clients/core/requests.d.ts:20


listByOrganization

listByOrganization(orgID, parameters?): Promise<object[]>

List all ticket requests by a specific organization.

Parameters

NameTypeDescription
orgIDnumberThe ID of the organization.
parameters?ObjectOptional parameters.
parameters.sort_by?stringSort by "updated_at" or "created_at".
parameters.sort_order?stringSort order: "asc" or "desc".

Returns

Promise<object[]>

List of ticket requests for the specified organization.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests

Example

ts
const orgRequests = await client.requests.listByOrganization(6789);

Defined in

clients/core/requests.d.ts:97


listByUser

listByUser(userID, parameters?): Promise<object[]>

List all ticket requests by a specific user.

Parameters

NameTypeDescription
userIDnumberThe ID of the user.
parameters?ObjectOptional parameters.
parameters.sort_by?stringSort by "updated_at" or "created_at".
parameters.sort_order?stringSort order: "asc" or "desc".

Returns

Promise<object[]>

List of ticket requests for the specified user.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests

Example

ts
const userRequests = await client.requests.listByUser(12345);

Defined in

clients/core/requests.d.ts:81


listCCD

listCCD(parameters?): Promise<object[]>

List all CCD ticket requests.

Parameters

NameTypeDescription
parameters?ObjectOptional parameters.
parameters.sort_by?stringSort by "updated_at" or "created_at".
parameters.sort_order?stringSort order: "asc" or "desc".

Returns

Promise<object[]>

List of CCD ticket requests.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests

Example

ts
const ccdRequests = await client.requests.listCCD();

Defined in

clients/core/requests.d.ts:65


listComments

listComments(requestId): Promise<object[]>

List all comments for a specific ticket request.

Parameters

NameTypeDescription
requestIdnumberThe ID of the ticket request.

Returns

Promise<object[]>

List of comments for the ticket request.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#listing-comments

Example

ts
const comments = await client.requests.listComments(1234);

Defined in

clients/core/requests.d.ts:178


listOpen

listOpen(parameters?): Promise<object[]>

List all ticket requests that are open.

Parameters

NameTypeDescription
parameters?ObjectOptional parameters.
parameters.sort_by?stringSort by "updated_at" or "created_at".
parameters.sort_order?stringSort order: "asc" or "desc".

Returns

Promise<object[]>

List of open ticket requests.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests

Example

ts
const openRequests = await client.requests.listOpen();

Defined in

clients/core/requests.d.ts:35


listSolved

listSolved(parameters?): Promise<object[]>

List all ticket requests that are solved.

Parameters

NameTypeDescription
parameters?ObjectOptional parameters.
parameters.sort_by?stringSort by "updated_at" or "created_at".
parameters.sort_order?stringSort order: "asc" or "desc".

Returns

Promise<object[]>

List of solved ticket requests.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests

Example

ts
const solvedRequests = await client.requests.listSolved();

Defined in

clients/core/requests.d.ts:50


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(parameters): Promise<object[]>

Search for ticket requests.

Parameters

NameTypeDescription
parametersObjectSearch parameters.
parameters.querystringThe query string.

Returns

Promise<object[]>

List of matching ticket requests.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#search-requests

Example

ts
const searchResults = await client.requests.search({ query: 'printer' });

Defined in

clients/core/requests.d.ts:111


setSideLoad

setSideLoad(array): void

Parameters

NameType
arrayany

Returns

void

Inherited from

Client.setSideLoad

Defined in

clients/client.d.ts:113


show

show(requestId): Promise<object>

Retrieve a specific ticket request.

Parameters

NameTypeDescription
requestIdnumberThe ID of the ticket request.

Returns

Promise<object>

The ticket request details.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#show-request

Example

ts
const requestDetails = await client.requests.show(1234);

Defined in

clients/core/requests.d.ts:123


update

update(requestId, updateDetails): Promise<object>

Update an existing ticket request.

Parameters

NameTypeDescription
requestIdnumberThe ID of the ticket request.
updateDetailsobjectDetails to update.

Returns

Promise<object>

The updated ticket request details.

Async

Throws

Throws an error if request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#update-request

Example

ts
const updatedInfo = {
  comment: {
    body: 'Thanks!'
  }
};
const updatedRequest = await client.requests.update(1234, updatedInfo);

Defined in

clients/core/requests.d.ts:168

Released under the MIT License.