//native
type Telnyx = {
apiKey: string
}
/**
* Update My Campaign
* Update a campaign's properties by `campaignId`. **Please note:** only sample messages are editable.
*/
export async function main(
auth: Telnyx,
campaignId: string,
body: {
resellerId?: string
sample1?: string
sample2?: string
sample3?: string
sample4?: string
sample5?: string
messageFlow?: string
helpMessage?: string
autoRenewal?: false | true
webhookURL?: string
webhookFailoverURL?: string
}
) {
const url = new URL(`https://api.telnyx.com/v2/campaign/${campaignId}`)
const response = await fetch(url, {
method: 'PUT',
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