//native
type Telnyx = {
apiKey: string
}
/**
* Create a comment
*
*/
export async function main(
auth: Telnyx,
body: {
id?: string
body?: string
commenter?: string
commenter_type?: 'admin' | 'user'
comment_record_type?: 'sub_number_order' | 'requirement_group'
comment_record_id?: string
read_at?: string
created_at?: string
updated_at?: string
}
) {
const url = new URL(`https://api.telnyx.com/v2/comments`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
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 428 days ago