//native
type Box = {
token: string;
};
/**
* List group collaborations
* Retrieves all the collaborations for a group. The user
must have admin permissions to inspect enterprise's groups.
Each collaboration object has details on which files or
folders the group has access to and with what role.
*/
export async function main(
auth: Box,
group_id: string,
limit: string | undefined,
offset: string | undefined,
) {
const url = new URL(
`https://api.box.com/2.0/groups/${group_id}/collaborations`,
);
for (const [k, v] of [
["limit", limit],
["offset", offset],
]) {
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