Skip to content

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

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new TicketFields(options): TicketFields

Parameters

NameType
optionsany

Returns

TicketFields

Overrides

Client.constructor

Defined in

clients/core/ticketfields.d.ts:161

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/ticketfields.d.ts:162


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


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


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

ts
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

NameTypeDescription
ticketFieldobjectThe 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

ts
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

NameTypeDescription
ticketFieldIdnumberThe ID of the ticket field.
optionobjectThe 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

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#create-or-update-ticket-field-option

Example

ts
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

NameTypeDescription
ticketFieldIdnumberThe 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

ts
const client = createClient({...});
await client.ticketfields.delete(12345);

Overrides

Client.delete

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

NameTypeDescription
ticketFieldIdnumberThe ID of the ticket field.
optionIDnumberThe ID of the option 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-option

Example

ts
const client = createClient({...});
await client.ticketfields.deleteOption(12345, 67890);

Defined in

clients/core/ticketfields.d.ts:306


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


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

ts
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

NameTypeDescription
ticketFieldIdnumberThe 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

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#list-ticket-field-options

Example

ts
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

NameTypeDescription
localestringThe 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

ts
const client = createClient({...});
const fields = await client.ticketfields.listWithLocale('sv');

Defined in

clients/core/ticketfields.d.ts:185


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


setSideLoad

setSideLoad(array): void

Parameters

NameType
arrayany

Returns

void

Inherited from

Client.setSideLoad

Defined in

clients/client.d.ts:113


show

show(ticketFieldId): Promise<TicketField>

Retrieves a specific ticket field by ID.

Parameters

NameTypeDescription
ticketFieldIdnumberThe 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

ts
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

NameTypeDescription
ticketFieldIdnumberThe ID of the ticket field.
optionIDnumberThe ID of the option to retrieve.

Returns

Promise<object>

Returns the option details.

Async

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#show-ticket-field-option

Example

ts
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

NameTypeDescription
ticketFieldIdnumberThe ID of the ticket field to update.
ticketFieldobjectThe 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

ts
const client = createClient({...});
const updatedField = await client.ticketfields.update(12345, {
  title: 'Updated Field'
});

Defined in

clients/core/ticketfields.d.ts:238

Released under the MIT License.