//native
type Square = {
token: string;
};
/**
* UpdateWorkweekConfig
* Updates a `WorkweekConfig`.
*/
export async function main(
auth: Square,
id: string,
body: {
workweek_config: {
id?: string;
start_of_week: "MON" | "TUE" | "WED" | "THU" | "FRI" | "SAT" | "SUN";
start_of_day_local_time: string;
version?: number;
created_at?: string;
updated_at?: string;
};
},
) {
const url = new URL(
`https://connect.squareup.com/v2/labor/workweek-configs/${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