//native
type Grist = {
apiKey: string;
host: string;
};
/**
* Change who has access to document
*
*/
export async function main(
auth: Grist,
docId: string,
body: {
delta: { maxInheritedRole?: "owners" | "editors" | "viewers"; users?: {} };
},
) {
const url = new URL(`https://${auth.host}/api/docs/${docId}/access`);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 329 days ago