//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Create a new attribute for a ticket type
* You can create a new attribute for a ticket type.
*/
export async function main(
auth: Intercom,
ticket_type_id: string,
body: {
name: string
description: string
data_type: 'string' | 'boolean' | 'list' | 'integer' | 'decimal' | 'datetime' | 'files'
required_to_create?: false | true
required_to_create_for_contacts?: false | true
visible_on_create?: false | true
visible_to_contacts?: false | true
multiline?: false | true
list_items?: string
allow_multiple_values?: false | true
}
) {
const url = new URL(`https://api.intercom.io/ticket_types/${ticket_type_id}/attributes`)
const response = await fetch(url, {
method: 'POST',
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