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

Returns the custom ticket status object.

Allowed For

  • End Users
Created by hugo697 605 days ago Viewed 22508 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 Custom Ticket Status
8
 * Returns the custom ticket status object.
9

10
#### Allowed For
11

12
* End Users
13

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

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