node-zendesk / Exports / clients/core/ticketfields / TicketFields
Class: TicketFields
clients/core/ticketfields.TicketFields
Client for the Zendesk Ticket Fields API.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/
Hierarchy
↳
TicketFields
Table of contents
Constructors
Properties
Accessors
Methods
- _rawRequest
- count
- create
- createOrUpdateOption
- delete
- deleteOption
- emit
- get
- getAll
- list
- listOptions
- listWithLocale
- on
- patch
- post
- put
- request
- requestAll
- requestUpload
- setSideLoad
- show
- showOption
- update
Constructors
constructor
• new TicketFields(options
): TicketFields
Parameters
Name | Type |
---|---|
options | any |
Returns
Overrides
Defined in
clients/core/ticketfields.d.ts:161
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/ticketfields.d.ts:162
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
count
▸ count(): Promise
<number
>
Retrieves the count of ticket fields.
Returns
Promise
<number
>
Returns the count of ticket fields.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#count-ticket-fields
Example
const client = createClient({...});
const count = await client.ticketfields.count();
Defined in
clients/core/ticketfields.d.ts:208
create
▸ create(ticketField
): Promise
<TicketField
>
Creates a new ticket field.
Parameters
Name | Type | Description |
---|---|---|
ticketField | object | The properties of the ticket field to create. |
Returns
Promise
<TicketField
>
Returns the created ticket field.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#create-ticket-field
Example
const client = createClient({...});
const newField = await client.ticketfields.create({
type: 'text',
title: 'New Field'
});
Defined in
clients/core/ticketfields.d.ts:223
createOrUpdateOption
▸ createOrUpdateOption(ticketFieldId
, option
): Promise
<object
>
Creates or updates an option of a ticket field.
Parameters
Name | Type | Description |
---|---|---|
ticketFieldId | number | The ID of the ticket field. |
option | object | The properties of the option to create or update. |
Returns
Promise
<object
>
Returns the created or updated option.
Async
Throws
Throws an error if the request fails.
See
Example
const client = createClient({...});
const newOption = await client.ticketfields.createOrUpdateOption(12345, {
custom_field_option: {
name: 'Option Name',
value: 'Option Value'
}
});
Defined in
clients/core/ticketfields.d.ts:293
delete
▸ delete(ticketFieldId
): Promise
<void
>
Deletes a specific ticket field by ID.
Parameters
Name | Type | Description |
---|---|---|
ticketFieldId | number | The ID of the ticket field to delete. |
Returns
Promise
<void
>
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#delete-ticket-field
Example
const client = createClient({...});
await client.ticketfields.delete(12345);
Overrides
Defined in
clients/core/ticketfields.d.ts:250
deleteOption
▸ deleteOption(ticketFieldId
, optionID
): Promise
<void
>
Deletes a specific option of a ticket field by ID.
Parameters
Name | Type | Description |
---|---|---|
ticketFieldId | number | The ID of the ticket field. |
optionID | number | The ID of the option to delete. |
Returns
Promise
<void
>
Async
Throws
Throws an error if the request fails.
See
Example
const client = createClient({...});
await client.ticketfields.deleteOption(12345, 67890);
Defined in
clients/core/ticketfields.d.ts:306
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
list
▸ list(): Promise
<TicketField
[]>
Lists all ticket fields.
Returns
Promise
<TicketField
[]>
} Returns an array of ticket fields.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#list-ticket-fields
Example
const client = createClient({...});
const fields = await client.ticketfields.list();
Defined in
clients/core/ticketfields.d.ts:173
listOptions
▸ listOptions(ticketFieldId
): Promise
<any
[]>
Lists all options of a ticket field.
Parameters
Name | Type | Description |
---|---|---|
ticketFieldId | number | The ID of the ticket field to retrieve options from. |
Returns
Promise
<any
[]>
Returns an array of options for the ticket field.
Async
Throws
Throws an error if the request fails.
See
Example
const client = createClient({...});
const options = await client.ticketfields.listOptions(12345);
Defined in
clients/core/ticketfields.d.ts:262
listWithLocale
▸ listWithLocale(locale
): Promise
<TicketField
[]>
Lists all ticket fields with locale.
Parameters
Name | Type | Description |
---|---|---|
locale | string | The locale code to filter ticket fields (e.g., 'sv' for Swedish). |
Returns
Promise
<TicketField
[]>
} Returns an array of ticket fields by locale.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#list-ticket-fields
Example
const client = createClient({...});
const fields = await client.ticketfields.listWithLocale('sv');
Defined in
clients/core/ticketfields.d.ts:185
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
setSideLoad
▸ setSideLoad(array
): void
Parameters
Name | Type |
---|---|
array | any |
Returns
void
Inherited from
Defined in
clients/client.d.ts:113
show
▸ show(ticketFieldId
): Promise
<TicketField
>
Retrieves a specific ticket field by ID.
Parameters
Name | Type | Description |
---|---|---|
ticketFieldId | number | The ID of the ticket field to retrieve. |
Returns
Promise
<TicketField
>
Returns the details of the ticket field.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#show-ticket-field
Example
const client = createClient({...});
const field = await client.ticketfields.show(12345);
Defined in
clients/core/ticketfields.d.ts:197
showOption
▸ showOption(ticketFieldId
, optionID
): Promise
<object
>
Retrieves a specific option of a ticket field by ID.
Parameters
Name | Type | Description |
---|---|---|
ticketFieldId | number | The ID of the ticket field. |
optionID | number | The ID of the option to retrieve. |
Returns
Promise
<object
>
Returns the option details.
Async
Throws
Throws an error if the request fails.
See
Example
const client = createClient({...});
const option = await client.ticketfields.showOption(12345, 67890);
Defined in
clients/core/ticketfields.d.ts:275
update
▸ update(ticketFieldId
, ticketField
): Promise
<TicketField
>
Updates a specific ticket field by ID.
Parameters
Name | Type | Description |
---|---|---|
ticketFieldId | number | The ID of the ticket field to update. |
ticketField | object | The updated properties of the ticket field. |
Returns
Promise
<TicketField
>
Returns the updated ticket field.
Async
Throws
Throws an error if the request fails.
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#update-ticket-field
Example
const client = createClient({...});
const updatedField = await client.ticketfields.update(12345, {
title: 'Updated Field'
});
Defined in
clients/core/ticketfields.d.ts:238