//native
/**
* Get User
* Retrieve a user (end user, agent or admin) by id.
*/
export async function main(auth: RT.Zendesk, user_id: number) {
const response = await fetch(
`https://${auth.subdomain}.zendesk.com/api/v2/users/${user_id}`,
{
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