Updates the specified webhook subscription.
1
type Bitbucket = {
2
username: string;
3
password: string;
4
};
5
/**
6
* Update a webhook for a workspace
7
* Updates the specified webhook subscription.
8
*/
9
export async function main(auth: Bitbucket, uid: string, workspace: string) {
10
const url = new URL(
11
`https://api.bitbucket.org/2.0/workspaces/${workspace}/hooks/${uid}`
12
);
13
14
const response = await fetch(url, {
15
method: "PUT",
16
headers: {
17
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
18
},
19
body: undefined,
20
});
21
if (!response.ok) {
22
const text = await response.text();
23
throw new Error(`${response.status} ${text}`);
24
}
25
return await response.json();
26
27