//native
type Clickup = {
token: string;
};
/**
* Retrieve Channels
* This endpoint retrieves the Channels in a Workspace.
*/
export async function main(
auth: Clickup,
workspace_id: string,
description_format: "text/md" | "text/plain" | undefined,
cursor: string | undefined,
limit: string | undefined,
is_follower: string | undefined,
include_hidden: string | undefined,
with_comment_since: string | undefined,
room_types: string | undefined,
) {
const url = new URL(
`https://api.clickup.com/api/v3/workspaces/${workspace_id}/chat/channels`,
);
for (const [k, v] of [
["description_format", description_format],
["cursor", cursor],
["limit", limit],
["is_follower", is_follower],
["include_hidden", include_hidden],
["with_comment_since", with_comment_since],
["room_types", room_types],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: 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