0

UpdateBreakType

by
Published Oct 17, 2025

Updates an existing `BreakType`.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * UpdateBreakType
7
 * Updates an existing `BreakType`.
8
 */
9
export async function main(
10
  auth: Square,
11
  id: string,
12
  body: {
13
    break_type: {
14
      id?: string;
15
      location_id: string;
16
      break_name: string;
17
      expected_duration: string;
18
      is_paid: false | true;
19
      version?: number;
20
      created_at?: string;
21
      updated_at?: string;
22
    };
23
  },
24
) {
25
  const url = new URL(
26
    `https://connect.squareup.com/v2/labor/break-types/${id}`,
27
  );
28

29
  const response = await fetch(url, {
30
    method: "PUT",
31
    headers: {
32
      "Content-Type": "application/json",
33
      Authorization: "Bearer " + auth.token,
34
    },
35
    body: JSON.stringify(body),
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43