//native
type Gorgias = {
username: string;
apiKey: string;
domain: string;
};
/**
* Retrieve a message
*
*/
export async function main(auth: Gorgias, ticket_id: string, id: string) {
const url = new URL(
`https://${auth.domain}.gorgias.com/api/tickets/${ticket_id}/messages/${id}/`,
);
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