//native
type Box = {
token: string;
};
/**
* List terms of services
* Returns the current terms of service text and settings
for the enterprise.
*/
export async function main(
auth: Box,
tos_type: "external" | "managed" | undefined,
) {
const url = new URL(`https://api.box.com/2.0/terms_of_services`);
for (const [k, v] of [["tos_type", tos_type]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago