//native
type Box = {
token: string;
};
/**
* Get trashed file
* Retrieves a file that has been moved to the trash.
Please note that only if the file itself has been moved to the
trash can it be retrieved with this API call. If instead one of
its parent folders was moved to the trash, only that folder
can be inspected using the
[`GET /folders/:id/trash`](e://get_folders_id_trash) API.
To list all items that have been moved to the trash, please
use the [`GET /folders/trash/items`](e://get-folders-trash-items/)
API.
*/
export async function main(
auth: Box,
file_id: string,
fields: string | undefined,
) {
const url = new URL(`https://api.box.com/2.0/files/${file_id}/trash`);
for (const [k, v] of [["fields", fields]]) {
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