1 | |
2 | type Telnyx = { |
3 | apiKey: string |
4 | } |
5 | |
6 | * Update a TeXML Application |
7 | * Updates settings of an existing TeXML Application. |
8 | */ |
9 | export async function main( |
10 | auth: Telnyx, |
11 | id: string, |
12 | body: { |
13 | friendly_name: string |
14 | active?: false | true |
15 | anchorsite_override?: |
16 | | 'Latency' |
17 | | 'Chicago, IL' |
18 | | 'Ashburn, VA' |
19 | | 'San Jose, CA' |
20 | | 'Sydney, Australia' |
21 | | 'Amsterdam, Netherlands' |
22 | | 'London, UK' |
23 | | 'Toronto, Canada' |
24 | | 'Vancouver, Canada' |
25 | | 'Frankfurt, Germany' |
26 | dtmf_type?: 'RFC 2833' | 'Inband' | 'SIP INFO' |
27 | first_command_timeout?: false | true |
28 | first_command_timeout_secs?: number |
29 | voice_url: string |
30 | voice_fallback_url?: string |
31 | voice_method?: 'get' | 'post' |
32 | status_callback?: string |
33 | status_callback_method?: 'get' | 'post' |
34 | inbound?: { |
35 | channel_limit?: number |
36 | shaken_stir_enabled?: false | true |
37 | sip_subdomain?: string |
38 | sip_subdomain_receive_settings?: 'only_my_connections' | 'from_anyone' |
39 | } |
40 | outbound?: { channel_limit?: number; outbound_voice_profile_id?: string } |
41 | } |
42 | ) { |
43 | const url = new URL(`https://api.telnyx.com/v2/texml_applications/${id}`) |
44 |
|
45 | const response = await fetch(url, { |
46 | method: 'PATCH', |
47 | headers: { |
48 | 'Content-Type': 'application/json', |
49 | Authorization: 'Bearer ' + auth.apiKey |
50 | }, |
51 | body: JSON.stringify(body) |
52 | }) |
53 | if (!response.ok) { |
54 | const text = await response.text() |
55 | throw new Error(`${response.status} ${text}`) |
56 | } |
57 | return await response.json() |
58 | } |
59 |
|