//native
type Telnyx = {
apiKey: string
}
/**
* Create a dynamic emergency address.
* Creates a dynamic emergency address.
*/
export async function main(
auth: Telnyx,
body: {
id?: string
record_type?: string
sip_geolocation_id?: string
status?: 'pending' | 'activated' | 'rejected'
house_number: string
house_suffix?: string
street_pre_directional?: string
street_name: string
street_suffix?: string
street_post_directional?: string
extended_address?: string
locality: string
administrative_area: string
postal_code: string
country_code?: 'US' | 'CA' | 'PR'
created_at?: string
updated_at?: string
}
) {
const url = new URL(`https://api.telnyx.com/v2/dynamic_emergency_addresses`)
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