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
↳
Requests
Table of contents
Constructors
Properties
Accessors
Methods
- _rawRequest
- create
- delete
- emit
- get
- getAll
- getComment
- getRequest
- list
- listByOrganization
- listByUser
- listCCD
- listComments
- listOpen
- listSolved
- on
- patch
- post
- put
- request
- requestAll
- requestUpload
- search
- setSideLoad
- show
- update
Constructors
constructor
• new Requests(options
): Requests
Parameters
Name | Type |
---|---|
options | any |
Returns
Overrides
Defined in
clients/core/requests.d.ts:2
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/requests.d.ts:3
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
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
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(requestDetails
): Promise
<object
>
Create a new ticket request.
Parameters
Name | Type | Description |
---|---|---|
requestDetails | object | Details 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
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
Name | Type | Description |
---|---|---|
...args | any [] | The resources or parts of the resource path. |
Returns
Promise
<void
| object
>
- Either void or response object
Inherited from
Defined in
clients/client.d.ts:128
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
getComment
▸ getComment(requestId
, commentId
): Promise
<object
>
Retrieve a specific comment from a ticket request.
Parameters
Name | Type | Description |
---|---|---|
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.
Async
Throws
Throws an error if request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#listing-comments
Example
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
Name | Type | Description |
---|---|---|
requestId | number | The 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
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
Name | Type | Description |
---|---|---|
parameters? | Object | 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.
Async
Throws
Throws an error if request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests
Example
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
Name | Type | Description |
---|---|---|
orgID | number | The ID of the organization. |
parameters? | Object | 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.
Async
Throws
Throws an error if request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests
Example
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
Name | Type | Description |
---|---|---|
userID | number | The ID of the user. |
parameters? | Object | 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.
Async
Throws
Throws an error if request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests
Example
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
Name | Type | Description |
---|---|---|
parameters? | Object | 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.
Async
Throws
Throws an error if request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests
Example
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
Name | Type | Description |
---|---|---|
requestId | number | The 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
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
Name | Type | Description |
---|---|---|
parameters? | Object | 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.
Async
Throws
Throws an error if request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests
Example
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
Name | Type | Description |
---|---|---|
parameters? | Object | 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.
Async
Throws
Throws an error if request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/#list-requests
Example
const solvedRequests = await client.requests.listSolved();
Defined in
clients/core/requests.d.ts:50
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
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
search
▸ search(parameters
): Promise
<object
[]>
Search for ticket requests.
Parameters
Name | Type | Description |
---|---|---|
parameters | Object | Search parameters. |
parameters.query | string | The 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
const searchResults = await client.requests.search({ query: 'printer' });
Defined in
clients/core/requests.d.ts:111
setSideLoad
▸ setSideLoad(array
): void
Parameters
Name | Type |
---|---|
array | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:113
show
▸ show(requestId
): Promise
<object
>
Retrieve a specific ticket request.
Parameters
Name | Type | Description |
---|---|---|
requestId | number | The 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
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
Name | Type | Description |
---|---|---|
requestId | number | The ID of the ticket request. |
updateDetails | object | Details 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
const updatedInfo = {
comment: {
body: 'Thanks!'
}
};
const updatedRequest = await client.requests.update(1234, updatedInfo);
Defined in
clients/core/requests.d.ts:168