type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Show Ticket After Changes
* Returns the full ticket object as it would be after applying the macro to the ticket.
It doesn't actually change the ticket.
To get only the ticket fields that would be changed by the macro,
see [Show Changes to Ticket](#show-changes-to-ticket).
#### Allowed For
* Agents
*/
export async function main(auth: Zendesk, ticket_id: string, macro_id: string) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/macros/${macro_id}/apply`
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 377 days ago
type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Show Ticket After Changes
* Returns the full ticket object as it would be after applying the macro to the ticket.
It doesn't actually change the ticket.
To get only the ticket fields that would be changed by the macro,
see [Show Changes to Ticket](#show-changes-to-ticket).
#### Allowed For
* Agents
*/
export async function main(auth: Zendesk, ticket_id: string, macro_id: string) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/macros/${macro_id}/apply`
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 923 days ago