Skip to content

node-zendeskDocs


node-zendesk / clients/core/requests / Requests

Class: 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.

Extends

Constructors

new Requests()

new Requests(options): Requests

Parameters

options: any

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:42


eventTarget

eventTarget: CustomEventTarget

Event target to handle custom events.

Inherited from

Client.eventTarget

Defined in

clients/client.d.ts:40


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: ZendeskClientOptions & object

Configuration options for the client.

Type declaration

get()

get: (key) => any

Parameters

key: string

Returns

any

Inherited from

Client.options

Defined in

clients/client.d.ts:34


sideLoad

sideLoad: any[]

Array to handle side-loaded resources.

Inherited from

Client.sideLoad

Defined in

clients/client.d.ts:37


sideLoadMap

sideLoadMap: object[]

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:39

Accessors

transporter

Get Signature

get transporter(): Transporter

Returns

Transporter

Transporter for making requests.

Inherited from

Client.transporter

Defined in

clients/client.d.ts:41

Methods

_rawRequest()

_rawRequest(method, uri, ...arguments_): Promise<object>

Parameters

method: any

uri: any

• ...arguments_: any[]

Returns

Promise<object>

response

response: any

result

result: object

Inherited from

Client._rawRequest

Defined in

clients/client.d.ts:78


create()

create(requestDetails): Promise<object>

Create a new ticket request.

Parameters

requestDetails: object

Details of the ticket request to be created.

Returns

Promise<object>

The created ticket request details.

response

response: object

result

result: object

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:150


delete()

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

Deletes a resource.

Parameters

• ...arguments_: any[]

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:76


emit()

emit(eventType, eventData): void

Parameters

eventType: any

eventData: any

Returns

void

Inherited from

Client.emit

Defined in

clients/client.d.ts:43


get()

get(resource): Promise<NodeModule>

Parameters

resource: any

Returns

Promise<NodeModule>

Inherited from

Client.get

Defined in

clients/client.d.ts:62


getAll()

getAll(resource): Promise<any[]>

Parameters

resource: any

Returns

Promise<any[]>

Inherited from

Client.getAll

Defined in

clients/client.d.ts:77


getComment()

getComment(requestId, commentId): Promise<object>

Retrieve a specific comment from a ticket request.

Parameters

requestId: number

The ID of the ticket request.

commentId: number

The ID of the comment to retrieve.

Returns

Promise<object>

The comment details for the specified ticket request.

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:191


getRequest()

getRequest(requestId): Promise<object>

Retrieve a specific ticket request.

Parameters

requestId: number

The ID of the ticket request.

Returns

Promise<object>

The ticket request details.

response

response: object

result

result: object

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:131


list()

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

List all ticket requests.

Parameters

parameters?

Optional parameters.

parameters.sort_by?: string

Sort by "updated_at" or "created_at".

parameters.sort_order?: string

Sort order: "asc" or "desc".

Returns

Promise<object[]>

List of ticket requests.

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:19


listByOrganization()

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

List all ticket requests by a specific organization.

Parameters

orgID: number

The ID of the organization.

parameters?

Optional parameters.

parameters.sort_by?: string

Sort by "updated_at" or "created_at".

parameters.sort_order?: string

Sort order: "asc" or "desc".

Returns

Promise<object[]>

List of ticket requests for the specified organization.

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:91


listByUser()

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

List all ticket requests by a specific user.

Parameters

userID: number

The ID of the user.

parameters?

Optional parameters.

parameters.sort_by?: string

Sort by "updated_at" or "created_at".

parameters.sort_order?: string

Sort order: "asc" or "desc".

Returns

Promise<object[]>

List of ticket requests for the specified user.

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:76


listCCD()

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

List all CCD ticket requests.

Parameters

parameters?

Optional parameters.

parameters.sort_by?: string

Sort by "updated_at" or "created_at".

parameters.sort_order?: string

Sort order: "asc" or "desc".

Returns

Promise<object[]>

List of CCD ticket requests.

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:61


listComments()

listComments(requestId): Promise<object[]>

List all comments for a specific ticket request.

Parameters

requestId: number

The ID of the ticket request.

Returns

Promise<object[]>

List of comments for the ticket request.

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:181


listOpen()

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

List all ticket requests that are open.

Parameters

parameters?

Optional parameters.

parameters.sort_by?: string

Sort by "updated_at" or "created_at".

parameters.sort_order?: string

Sort order: "asc" or "desc".

Returns

Promise<object[]>

List of open ticket requests.

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:33


listSolved()

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

List all ticket requests that are solved.

Parameters

parameters?

Optional parameters.

parameters.sort_by?: string

Sort by "updated_at" or "created_at".

parameters.sort_order?: string

Sort order: "asc" or "desc".

Returns

Promise<object[]>

List of solved ticket requests.

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:47


on()

on(eventType, callback): void

Parameters

eventType: any

callback: any

Returns

void

Inherited from

Client.on

Defined in

clients/client.d.ts:44


patch()

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

Patches a resource.

Parameters

• ...arguments_: any[]

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:68


post()

post(resource, body): Promise<NodeModule>

Parameters

resource: any

body: any

Returns

Promise<NodeModule>

Inherited from

Client.post

Defined in

clients/client.d.ts:70


put()

put(resource, body): Promise<NodeModule>

Parameters

resource: any

body: any

Returns

Promise<NodeModule>

Inherited from

Client.put

Defined in

clients/client.d.ts:69


request()

request<T>(method, uri, ...arguments_): Promise<NodeModule>

Request method that handles various HTTP methods.

Type Parameters

T

Parameters

method: string

HTTP method (e.g., 'GET', 'POST').

uri: string

The URI for the request.

• ...arguments_: any[]

Additional arguments for the request.

Returns

Promise<NodeModule>

  • The API response.

Inherited from

Client.request

Defined in

clients/client.d.ts:96


requestAll()

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

Parameters

method: any

uri: any

• ...arguments_: any[]

Returns

Promise<any[]>

Inherited from

Client.requestAll

Defined in

clients/client.d.ts:97


requestUpload()

requestUpload(uri, file): Promise<any>

Parameters

uri: any

file: any

Returns

Promise<any>

Inherited from

Client.requestUpload

Defined in

clients/client.d.ts:98


search(parameters): Promise<object>

Search for ticket requests.

Parameters

parameters

Search parameters.

parameters.query: string

The query string.

Returns

Promise<object>

List of matching ticket requests.

response

response: object

result

result: object[]

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:104


setSideLoad()

setSideLoad(array): void

Parameters

array: any

Returns

void

Inherited from

Client.setSideLoad

Defined in

clients/client.d.ts:61


show()

show(requestId): Promise<object>

Retrieve a specific ticket request.

Parameters

requestId: number

The ID of the ticket request.

Returns

Promise<object>

The ticket request details.

response

response: object

result

result: object

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:118


update()

update(requestId, updateDetails): Promise<object>

Update an existing ticket request.

Parameters

requestId: number

The ID of the ticket request.

updateDetails: object

Details to update.

Returns

Promise<object>

The updated ticket request details.

response

response: object

result

result: object

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:169

Released under the MIT License.