//native
type Box = {
token: string;
};
/**
* Update web link
* Updates a web link object.
*/
export async function main(
auth: Box,
web_link_id: string,
body: {
url?: string;
parent?: { id?: string; user_id?: string } & {};
name?: string;
description?: string;
shared_link?: {
access?: "open" | "company" | "collaborators";
password?: string;
vanity_name?: string;
unshared_at?: string;
};
},
) {
const url = new URL(`https://api.box.com/2.0/web_links/${web_link_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