node-zendesk / Exports / clients/core/attachments / Attachments
Class: Attachments
clients/core/attachments.Attachments
Represents the Attachments functionality of the Zendesk API.
See
[Zendesk Attachments API]https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-attachments/
Hierarchy
↳
Attachments
Table of contents
Constructors
Properties
Accessors
Methods
- _rawRequest
- delete
- deleteUpload
- emit
- get
- getAll
- on
- patch
- post
- put
- redactAttachmentComment
- request
- requestAll
- requestUpload
- setSideLoad
- show
- updateAttachmentForMalware
- upload
Constructors
constructor
• new Attachments(options
, apiType
): Attachments
Parameters
Name | Type | Description |
---|---|---|
options | ClientOptions | Configuration options for the client. |
apiType | string | Type of Zendesk API to initialize (e.g., 'core', 'helpcenter'). |
Returns
Constructs
Client
Inherited from
Defined in
clients/client.d.ts:85
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: any
[]
Array to hold names used in the JSON API.
Inherited from
Defined in
clients/client.d.ts:90
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
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
deleteUpload
▸ deleteUpload(token
): Promise
<object
>
Delete an uploaded file.
Parameters
Name | Type | Description |
---|---|---|
token | string | The token of the uploaded attachment. |
Returns
Promise
<object
>
Returns the server's response.
Async
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-attachments/#delete-upload
Example
const response = await client.attachments.deleteUpload("exampleToken");
Defined in
clients/core/attachments.d.ts:34
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
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
redactAttachmentComment
▸ redactAttachmentComment(ticketID
, commentID
, attachmentID
): Promise
<object
>
Redact an attachment from an existing comment on a ticket.
Parameters
Name | Type | Description |
---|---|---|
ticketID | number | The ID of the ticket. |
commentID | number | The ID of the comment. |
attachmentID | number | The ID of the attachment. |
Returns
Promise
<object
>
Returns the server's response.
Async
See
Example
const response = await client.attachments.redactAttachmentComment(1, 2, 3);
Defined in
clients/core/attachments.d.ts:56
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(attachmentID
): Promise
<object
>
Retrieve details of a specific attachment.
Parameters
Name | Type | Description |
---|---|---|
attachmentID | number | The ID of the attachment. |
Returns
Promise
<object
>
Returns the details of the attachment.
Async
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-attachments/#show-attachment
Example
const attachmentDetails = await client.attachments.show(12345);
Defined in
clients/core/attachments.d.ts:44
updateAttachmentForMalware
▸ updateAttachmentForMalware(attachmentID
, malwareAccessOverride
): Promise
<object
>
Toggles enabling or restricting agent access to attachments with detected malware.
Parameters
Name | Type | Description |
---|---|---|
attachmentID | number | The ID of the attachment. |
malwareAccessOverride | boolean | Whether to override malware access. If true, agent can access attachment flagged as malware. |
Returns
Promise
<object
>
The response from the Zendesk API.
Async
Throws
Throws an error if the request fails.
See
Example
const result = await client.attachments.updateAttachmentForMalware(928374, true);
console.log(result);
Defined in
clients/core/attachments.d.ts:69
upload
▸ upload(file
, fileOptions
): Promise
<object
>
Upload a file to be attached to a ticket comment.
Parameters
Name | Type | Description |
---|---|---|
file | Buffer | The file data. |
fileOptions | Object | Options for the file. |
fileOptions.binary | boolean | If the file is binary or not. |
fileOptions.filename | string | Name of the file when attached to the ticket comment. |
fileOptions.token? | string | Token received from previous uploads (if multiple files are being attached). |
Returns
Promise
<object
>
Returns the server's response.
Async
See
https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-attachments/#upload-files
Example
const response = await client.attachments.upload(fileBuffer, { filename: "example.png", binary: true });
Defined in
clients/core/attachments.d.ts:20