//native
type Gorgias = {
username: string;
apiKey: string;
domain: string;
};
/**
* Delete customers
*
*/
export async function main(auth: Gorgias, body: { ids: number[] }) {
const url = new URL(`https://${auth.domain}.gorgias.com/api/customers`);
const response = await fetch(url, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${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 235 days ago