//native
type Gorgias = {
username: string;
apiKey: string;
domain: string;
};
/**
* Delete a rule
*
*/
export async function main(auth: Gorgias, id: string) {
const url = new URL(`https://${auth.domain}.gorgias.com/api/rules/${id}/`);
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.apiKey}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago