//native
type Square = {
token: string;
};
/**
* UpdateBreakType
* Updates an existing `BreakType`.
*/
export async function main(
auth: Square,
id: string,
body: {
break_type: {
id?: string;
location_id: string;
break_name: string;
expected_duration: string;
is_paid: false | true;
version?: number;
created_at?: string;
updated_at?: string;
};
},
) {
const url = new URL(
`https://connect.squareup.com/v2/labor/break-types/${id}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago