1 | |
2 | type Gitbook = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Move a site space to a new position. (Deprecated) use sortSiteStructure instead. |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Gitbook, |
11 | organizationId: string, |
12 | siteId: string, |
13 | siteSpaceId: string, |
14 | body: { |
15 | position?: { |
16 | before?: { type: "site-space"; siteSpace: string }; |
17 | after?: { type: "site-space"; siteSpace: string }; |
18 | }; |
19 | }, |
20 | ) { |
21 | const url = new URL( |
22 | `https://api.gitbook.com/v1/orgs/${organizationId}/sites/${siteId}/site-spaces/${siteSpaceId}/move`, |
23 | ); |
24 |
|
25 | const response = await fetch(url, { |
26 | method: "POST", |
27 | headers: { |
28 | "Content-Type": "application/json", |
29 | Authorization: "Bearer " + auth.token, |
30 | }, |
31 | body: JSON.stringify(body), |
32 | }); |
33 | if (!response.ok) { |
34 | const text = await response.text(); |
35 | throw new Error(`${response.status} ${text}`); |
36 | } |
37 | return await response.json(); |
38 | } |
39 |
|