//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Update a ticket
* You can update a ticket.
*/
export async function main(
auth: Intercom,
id: string,
body: {
ticket_attributes?: {}
state?: 'in_progress' | 'waiting_on_customer' | 'resolved'
open?: false | true
is_shared?: false | true
snoozed_until?: number
assignment?: { admin_id?: string; assignee_id?: string }
}
) {
const url = new URL(`https://api.intercom.io/tickets/${id}`)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Intercom-Version': auth.apiVersion,
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 536 days ago