//native
type Telnyx = {
apiKey: string
}
/**
* Create Default Gateway.
* Create Default Gateway.
*/
export async function main(
auth: Telnyx,
id: string,
body: {
id?: string
record_type?: string
created_at?: string
updated_at?: string
} & {
record_type?: string
network_id?: string
wireguard_peer_id?: string
status?: 'created' | 'provisioning' | 'provisioned' | 'deleting'
}
) {
const url = new URL(`https://api.telnyx.com/v2/networks/${id}/default_gateway`)
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