//native
type Box = {
token: string;
};
/**
* Create folder lock
* Creates a folder lock on a folder, preventing it from being moved and/or
deleted.
You must be authenticated as the owner or co-owner of the folder to
use this endpoint.
*/
export async function main(
auth: Box,
body: {
locked_operations?: { move: false | true; delete: false | true };
folder: { type: string; id: string };
},
) {
const url = new URL(`https://api.box.com/2.0/folder_locks`);
const response = await fetch(url, {
method: "POST",
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