//native
type Box = {
token: string;
};
/**
* List trashed items
* Retrieves the files and folders that have been moved
to the trash.
Any attribute in the full files or folders objects can be passed
in with the `fields` parameter to retrieve those specific
attributes that are not returned by default.
This endpoint defaults to use offset-based pagination, yet also supports
marker-based pagination using the `marker` parameter.
*/
export async function main(
auth: Box,
fields: string | undefined,
limit: string | undefined,
offset: string | undefined,
usemarker: string | undefined,
marker: string | undefined,
direction: "ASC" | "DESC" | undefined,
sort: "name" | "date" | "size" | undefined,
) {
const url = new URL(`https://api.box.com/2.0/folders/trash/items`);
for (const [k, v] of [
["fields", fields],
["limit", limit],
["offset", offset],
["usemarker", usemarker],
["marker", marker],
["direction", direction],
["sort", sort],
]) {
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