Edits history of script submission #13604 for ' Update a conference resource (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Update a conference resource
     * Updates a conference resource.
     */
    export async function main(
    	auth: Telnyx,
    	account_sid: string,
    	conference_sid: string,
    	body: {
    		Status?: string
    		AnnounceUrl?: string
    		AnnounceMethod?: 'GET' | 'POST'
    	}
    ) {
    	const url = new URL(
    		`https://api.telnyx.com/v2/texml/Accounts/${account_sid}/Conferences/${conference_sid}`
    	)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/x-www-form-urlencoded',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: new URLSearchParams(body as Record<string, string>)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 428 days ago