0
Show Suspended Ticket
One script reply has been approved by the moderators Verified

Allowed For

Created by hugo697 605 days ago Viewed 22439 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 605 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Show Suspended Ticket
8
 * #### Allowed For
9

10
* Admins and [agents in custom roles with permission](https://support.zendesk.com/hc/en-us/articles/4408882153882#topic_cxn_hig_bd) to manage suspended tickets on Enterprise plans
11
* Unrestricted agents on all other plans
12

13
 */
14
export async function main(auth: Zendesk, id: string) {
15
  const url = new URL(
16
    `https://${auth.subdomain}.zendesk.com/api/v2/suspended_tickets/${id}`
17
  );
18

19
  const response = await fetch(url, {
20
    method: "GET",
21
    headers: {
22
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
23
    },
24
    body: undefined,
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.json();
31
}
32