Moves a folder.
1
//native
2
type Smartsheet = {
3
token: string;
4
baseUrl: string;
5
};
6
/**
7
* Move Folder
8
* Moves a folder.
9
*/
10
export async function main(
11
auth: Smartsheet,
12
folderId: string,
13
body: {
14
destinationId: number;
15
destinationType?: "folder" | "home" | "workspace";
16
},
17
) {
18
const url = new URL(`${auth.baseUrl}/folders/${folderId}/move`);
19
20
const response = await fetch(url, {
21
method: "POST",
22
headers: {
23
"Content-Type": "application/json",
24
Authorization: "Bearer " + auth.token,
25
26
body: JSON.stringify(body),
27
});
28
if (!response.ok) {
29
const text = await response.text();
30
throw new Error(`${response.status} ${text}`);
31
}
32
return await response.json();
33
34