//native
type Gorgias = {
username: string;
apiKey: string;
domain: string;
};
/**
* List views
* List all views ordered by their `display_order` attribute, with the smallest position first. Current user variables (`{{current_user...}}`) present in views' filters will be replaced with the information of the user listing views.
*/
export async function main(auth: Gorgias) {
const url = new URL(`https://${auth.domain}.gorgias.com/api/views`);
const response = await fetch(url, {
method: "GET",
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.json();
}
Submitted by hugo697 235 days ago