//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Set an admin to away
* You can set an Admin as away for the Inbox.
*/
export async function main(
auth: Intercom,
id: string,
body: { away_mode_enabled: false | true; away_mode_reassign: false | true }
) {
const url = new URL(`https://api.intercom.io/admins/${id}/away`)
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