Skip to content

node-zendesk / Exports / clients/core/groups / Groups

Class: Groups

clients/core/groups.Groups

A client for interfacing with the Zendesk Groups API.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Groups(options): Groups

Parameters

NameType
optionsany

Returns

Groups

Overrides

Client.constructor

Defined in

clients/core/groups.d.ts:72

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/groups.d.ts:73


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: { all: boolean ; dataset: string ; field: string ; name: string }[]

Defined in

clients/core/groups.d.ts:74


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


assignable

assignable(): Promise<object>

Retrieves a list of all assignable groups.

Returns

Promise<object>

A promise that resolves to the list of assignable groups.

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/#list-assignable-groups

Example

ts
const assignableGroups = await client.groups.assignable();

Defined in

clients/core/groups.d.ts:117


count

count(): Promise<object>

Retrieves an approximate count of groups. If the count exceeds 100,000, it is updated every 24 hours.

Returns

Promise<object>

A promise that resolves to the group count data.

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/#count-groups

Example

ts
const count = await client.groups.count();

Defined in

clients/core/groups.d.ts:98


countByUser

countByUser(userID): Promise<object>

Retrieves the approximate count of groups for a specified user.

Parameters

NameTypeDescription
userIDnumberThe ID of the user for whom to count the groups.

Returns

Promise<object>

A promise that resolves to the approximate count of groups for the user.

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/#count-groups

Example

ts
const groupCount = await client.groups.countByUser(12345);

Defined in

clients/core/groups.d.ts:108


create

create(group): Promise<{ result: Group }>

Creates a new group.

Parameters

NameTypeDescription
groupCreateOrUpdateGroupThe group details to create.

Returns

Promise<{ result: Group }>

A promise that resolves to the details of the created group.

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/#create-group

Example

ts
const newGroup = {
  name: "Support Team",
  description: "Handles support tickets"
};
const createdGroup = await client.groups.create(newGroup);

Defined in

clients/core/groups.d.ts:143


delete

delete(groupID): Promise<object>

Deletes a specified group by its ID.

Parameters

NameTypeDescription
groupIDnumberThe ID of the group to delete.

Returns

Promise<object>

A promise that resolves to the response data (might be empty or a confirmation).

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/#delete-group

Example

ts
await client.groups.delete(12345);

Overrides

Client.delete

Defined in

clients/core/groups.d.ts:171


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<Group[]>

Retrieves a list of all groups.

Returns

Promise<Group[]>

A promise that resolves to the list of groups.

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/#list-groups

Example

ts
const allGroups = await client.groups.list();

Defined in

clients/core/groups.d.ts:88


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(groupID): Promise<{ result: Group }>

Retrieves details of a specific group by its ID.

Parameters

NameTypeDescription
groupIDnumberThe ID of the group.

Returns

Promise<{ result: Group }>

A promise that resolves to the group's details.

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/#show-group

Example

ts
const groupDetails = await client.groups.show(12345);

Defined in

clients/core/groups.d.ts:127


update

update(groupID, group): Promise<{ result: Group }>

Updates a specified group.

Parameters

NameTypeDescription
groupIDnumberThe ID of the group to update.
groupCreateOrUpdateGroupThe updated group details.

Returns

Promise<{ result: Group }>

A promise that resolves to the details of the updated group.

Throws

Throws an error if the request fails.

See

https://developer.zendesk.com/api-reference/ticketing/groups/groups/#update-group

Example

ts
const updatedInfo = {
  name: "Updated Support Team"
};
const updatedGroup = await client.groups.update(12345, updatedInfo);

Defined in

clients/core/groups.d.ts:159

Released under the MIT License.