1 | type Trello = { |
2 | key: string; |
3 | token: string; |
4 | }; |
5 | |
6 | * Get ClaimableOrganizations of an Enterprise |
7 | * Get the Workspaces that are claimable by the enterprise by ID. Can optionally query for workspaces based on activeness/ inactiveness. |
8 | */ |
9 | export async function main( |
10 | auth: Trello, |
11 | id: string, |
12 | limit: string | undefined, |
13 | cursor: string | undefined, |
14 | name: string | undefined, |
15 | activeSince: string | undefined, |
16 | inactiveSince: string | undefined |
17 | ) { |
18 | const url = new URL( |
19 | `https://api.trello.com/1/enterprises/${id}/claimableOrganizations` |
20 | ); |
21 | for (const [k, v] of [ |
22 | ["limit", limit], |
23 | ["cursor", cursor], |
24 | ["name", name], |
25 | ["activeSince", activeSince], |
26 | ["inactiveSince", inactiveSince], |
27 | ["key", auth.key], |
28 | ["token", auth.token], |
29 | ]) { |
30 | if (v !== undefined && v !== "") { |
31 | url.searchParams.append(k, v); |
32 | } |
33 | } |
34 | const response = await fetch(url, { |
35 | method: "GET", |
36 | headers: { |
37 | Authorization: undefined, |
38 | }, |
39 | body: undefined, |
40 | }); |
41 | if (!response.ok) { |
42 | const text = await response.text(); |
43 | throw new Error(`${response.status} ${text}`); |
44 | } |
45 | return await response.json(); |
46 | } |
47 |
|