//native
/**
* List Side Conversations
* List a ticket's side conversations, optionally with their events (the messages sent and received).
*/
export async function main(
auth: RT.Zendesk,
ticket_id: number,
include_events: boolean
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/side_conversations`
)
if (include_events) {
url.searchParams.append("include", "events")
}
const response = await fetch(url, {
headers: {
Authorization: auth.token
? `Bearer ${auth.token}`
: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago