Skip to content

node-zendesk / Exports / clients/core/views / Views

Class: Views

clients/core/views.Views

Represents the Views API methods.

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Views(options): Views

Parameters

NameType
optionsany

Returns

Views

Overrides

Client.constructor

Defined in

clients/core/views.d.ts:6

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


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


create

create(view): Promise<object>

Creates a new view.

Parameters

NameTypeDescription
viewobjectThe view data to create.

Returns

Promise<object>

A promise that resolves to the created view details.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#create-view

Example

ts
const newView = {
  title: "My New View",
  conditions: {...}
};
const createdView = await client.views.create(newView);

Defined in

clients/core/views.d.ts:58


delete

delete(viewID): Promise<object>

Deletes a specific view by its ID.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view to delete.

Returns

Promise<object>

A promise that resolves when the view is deleted.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#delete-view

Overrides

Client.delete

Defined in

clients/core/views.d.ts:163


emit

emit(eventType, eventData): void

Parameters

NameType
eventTypeany
eventDataany

Returns

void

Inherited from

Client.emit

Defined in

clients/client.d.ts:95


execute

execute(viewID, parameters): Promise<object>

Executes a specific view by its ID.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view to execute.
parametersobjectAdditional parameters for execution.

Returns

Promise<object>

A promise that resolves to the executed view results.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#execute-view

Example

ts
const executedView = await client.views.execute(12345, {sort_by: 'status'});

Defined in

clients/core/views.d.ts:82


export

export(viewID): Promise<object>

Exports views to a JSON file.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view to export.

Returns

Promise<object>

A promise that resolves to the exported views in JSON format.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#export-view

Example

ts
const exportedViews = await client.views.export([12345, 67890]);

Defined in

clients/core/views.d.ts:132


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<object>

Lists shared and personal views available to the current user.

Returns

Promise<object>

A promise that resolves to the list of views.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-views

Example

ts
const views = await client.views.list();

Defined in

clients/core/views.d.ts:16


listActive

listActive(): Promise<object>

Lists active shared and personal views available to the current user.

Returns

Promise<object>

A promise that resolves to the list of active views.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-active-views

Example

ts
const activeViews = await client.views.listActive();

Defined in

clients/core/views.d.ts:25


listActiveShared

listActiveShared(): Promise<object>

Retrieves all active shared views.

Returns

Promise<object>

A promise that resolves to the list of all active shared views.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-active-shared-views

Defined in

clients/core/views.d.ts:139


listCompact

listCompact(): Promise<object>

A compacted list of shared and personal views available to the current user.

Returns

Promise<object>

A promise that resolves to the compact list of views.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-views-compact

Example

ts
const compactViews = await client.views.listCompact();

Defined in

clients/core/views.d.ts:34


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


preview

preview(parameters): Promise<object>

Previews a new view without saving it.

Parameters

NameTypeDescription
parametersobjectAdditional parameters for execution.

Returns

Promise<object>

A promise that resolves to the previewed view results.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#preview-view

Example

ts
const viewData = {
  title: "Preview View",
  conditions: {...}
};
const previewResults = await client.views.preview(viewData);

Defined in

clients/core/views.d.ts:105


put

put(resource, body): Promise<NodeModule>

Parameters

NameType
resourceany
bodyany

Returns

Promise<NodeModule>

Inherited from

Client.put

Defined in

clients/client.d.ts:121


reorder

reorder(viewOrder): Promise<object>

Reorders views based on the provided order.

Parameters

NameTypeDescription
viewOrdernumber[]An array of view IDs in the desired order.

Returns

Promise<object>

A promise that resolves when the views are reordered.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#reorder-views

Defined in

clients/core/views.d.ts:171


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(viewID): Promise<object>

Shows details of a specific view.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view to retrieve.

Returns

Promise<object>

A promise that resolves to the details of the view.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-view

Example

ts
const viewDetails = await client.views.show(12345);

Defined in

clients/core/views.d.ts:44


showCount

showCount(viewID): Promise<object>

Retrieves the count of tickets for a specific view.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view to count tickets for.

Returns

Promise<object>

A promise that resolves to the ticket count for the view.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-view-count

Example

ts
const ticketCount = await client.views.showCount(12345);

Defined in

clients/core/views.d.ts:114


showCounts

showCounts(viewIDs): Promise<object>

Retrieves the ticket counts for multiple views.

Parameters

NameTypeDescription
viewIDsnumber[]An array of view IDs to count tickets for.

Returns

Promise<object>

A promise that resolves to the ticket counts for the specified views.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-multiple-view-counts

Example

ts
const ticketCounts = await client.views.showCounts([12345, 67890]);

Defined in

clients/core/views.d.ts:123


showExecutionStatus

showExecutionStatus(viewID): Promise<object>

Retrieves the view's execution status.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view to check the execution status for.

Returns

Promise<object>

A promise that resolves to the execution status of the view.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-view-execution-status

Defined in

clients/core/views.d.ts:147


showRecentTicketIDs

showRecentTicketIDs(viewID): Promise<object>

Retrieves the view's recent ticket IDs.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view to retrieve recent ticket IDs for.

Returns

Promise<object>

A promise that resolves to the recent ticket IDs of the view.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-view-recent-ticket-ids

Defined in

clients/core/views.d.ts:155


tickets

tickets(viewID): Promise<object>

Retrieves tickets from a specific view by its ID.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view.

Returns

Promise<object>

A promise that resolves to the list of tickets from the view.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-tickets-from-a-view

Example

ts
const ticketsFromView = await client.views.tickets(12345);

Defined in

clients/core/views.d.ts:91


update

update(viewID, viewData): Promise<object>

Updates an existing view by its ID.

Parameters

NameTypeDescription
viewIDnumberThe ID of the view to update.
viewDataobjectThe updated view data.

Returns

Promise<object>

A promise that resolves to the updated view details.

Async

See

https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#update-view

Example

ts
const updatedData = {
  title: "Updated View Title"
};
const updatedView = await client.views.update(12345, updatedData);

Defined in

clients/core/views.d.ts:72

Released under the MIT License.