//native
type Kustomer = {
apiKey: string;
};
/**
* Update Category
* Updates any requested category (both internal and public).
*/
export async function main(
auth: Kustomer,
id: string,
body: {
parent?: string;
langs?: {};
deleted?: true;
externalId?: string;
positions?: string[];
categoryPositions?: string[];
icon?: string;
},
) {
const url = new URL(`https://api.kustomerapp.com/v1/kb/categories/${id}`);
const response = await fetch(url, {
method: "PUT",
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.json();
}
Submitted by hugo697 235 days ago