//native
type Circleci = {
token: string
}
/**
* Update an outbound webhook
* Updates an outbound webhook.
*/
export async function main(
auth: Circleci,
webhook_id: string,
body: {
name?: string
events?: 'workflow-completed' | 'job-completed'[]
url?: string
'signing-secret'?: string
'verify-tls'?: false | true
}
) {
const url = new URL(`https://circleci.com/api/v2/webhook/${webhook_id}`)
const response = await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Circle-Token': auth.token
},
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 536 days ago