type Bitbucket = {
username: string;
password: string;
};
/**
* Vote for an issue
* Vote for this issue.
To cast your vote, do an empty PUT. The 204 status code indicates that
the operation was successful.
*/
export async function main(
auth: Bitbucket,
issue_id: string,
repo_slug: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}/vote`
);
const response = await fetch(url, {
method: "PUT",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 415 days ago