//native
type Telnyx = {
apiKey: string
}
/**
* Update call
* Update TeXML call. Please note that the keys present in the payload MUST BE formatted in CamelCase as specified in the example.
*/
export async function main(
auth: Telnyx,
call_sid: string,
body: {
Status?: string
Url?: string
Method?: 'GET' | 'POST'
FallbackUrl?: string
FallbackMethod?: 'GET' | 'POST'
StatusCallback?: string
StatusCallbackMethod?: 'GET' | 'POST'
Texml?: string
}
) {
const url = new URL(`https://api.telnyx.com/v2/texml/calls/${call_sid}/update`)
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