Edits history of script submission #13598 for ' Update a TeXML Application (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Update a TeXML Application
     * Updates settings of an existing TeXML Application.
     */
    export async function main(
    	auth: Telnyx,
    	id: string,
    	body: {
    		friendly_name: string
    		active?: false | true
    		anchorsite_override?:
    			| 'Latency'
    			| 'Chicago, IL'
    			| 'Ashburn, VA'
    			| 'San Jose, CA'
    			| 'Sydney, Australia'
    			| 'Amsterdam, Netherlands'
    			| 'London, UK'
    			| 'Toronto, Canada'
    			| 'Vancouver, Canada'
    			| 'Frankfurt, Germany'
    		dtmf_type?: 'RFC 2833' | 'Inband' | 'SIP INFO'
    		first_command_timeout?: false | true
    		first_command_timeout_secs?: number
    		voice_url: string
    		voice_fallback_url?: string
    		voice_method?: 'get' | 'post'
    		status_callback?: string
    		status_callback_method?: 'get' | 'post'
    		inbound?: {
    			channel_limit?: number
    			shaken_stir_enabled?: false | true
    			sip_subdomain?: string
    			sip_subdomain_receive_settings?: 'only_my_connections' | 'from_anyone'
    		}
    		outbound?: { channel_limit?: number; outbound_voice_profile_id?: string }
    	}
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/texml_applications/${id}`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		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