//native
type Box = {
token: string;
};
/**
* List enterprise device pins
* Retrieves all the device pins within an enterprise.
The user must have admin privileges, and the application
needs the "manage enterprise" scope to make this call.
*/
export async function main(
auth: Box,
enterprise_id: string,
marker: string | undefined,
limit: string | undefined,
direction: "ASC" | "DESC" | undefined,
) {
const url = new URL(
`https://api.box.com/2.0/enterprises/${enterprise_id}/device_pinners`,
);
for (const [k, v] of [
["marker", marker],
["limit", limit],
["direction", direction],
]) {
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