//native
type Gitbook = {
token: string;
};
/**
* Update glossary entries
*
*/
export async function main(
auth: Gitbook,
organizationId: string,
body: {
operations:
| { type: "insert"; translations: {} }
| { type: "update"; id: string; translations: {} }
| { type: "delete"; id: string }[];
},
) {
const url = new URL(
`https://api.gitbook.com/v1/orgs/${organizationId}/translations-glossary`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
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 235 days ago