Show Many Ticket Forms

Takes an `ids` query parameter that accepts a comma-separated list of up to 100 ticket form ids. This endpoint is used primarily by the mobile SDK and the Web Widget. #### Allowed For * Anyone

Script zendesk Verified

by hugo697 ยท 11/7/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 377 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Show Many Ticket Forms
8
 * Takes an `ids` query parameter that accepts a comma-separated list of up to 100 ticket form ids. This endpoint is used primarily by the mobile SDK and the Web Widget.
9

10
#### Allowed For
11

12
* Anyone
13

14
 */
15
export async function main(
16
  auth: Zendesk,
17
  ids: string | undefined,
18
  active: string | undefined,
19
  end_user_visible: string | undefined,
20
  fallback_to_default: string | undefined,
21
  associated_to_brand: string | undefined
22
) {
23
  const url = new URL(
24
    `https://${auth.subdomain}.zendesk.com/api/v2/ticket_forms/show_many`
25
  );
26
  for (const [k, v] of [
27
    ["ids", ids],
28
    ["active", active],
29
    ["end_user_visible", end_user_visible],
30
    ["fallback_to_default", fallback_to_default],
31
    ["associated_to_brand", associated_to_brand],
32
  ]) {
33
    if (v !== undefined && v !== "") {
34
      url.searchParams.append(k, v);
35
    }
36
  }
37
  const response = await fetch(url, {
38
    method: "GET",
39
    headers: {
40
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
41
    },
42
    body: undefined,
43
  });
44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48
  return await response.json();
49
}
50