//native
type Telnyx = {
apiKey: string
}
/**
* Update auto recharge preferences
* Update payment auto recharge preferences.
*/
export async function main(
auth: Telnyx,
body: {
threshold_amount?: string
recharge_amount?: string
enabled?: false | true
invoice_enabled?: false | true
preference?: 'credit_paypal' | 'ach'
}
) {
const url = new URL(`https://api.telnyx.com/v2/payment/auto_recharge_prefs`)
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