type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Add filter as favorite
* Add a filter as a favorite for the user.
**[Permissions](#permissions) required:** Permission to access Jira, however, the user can only favorite:
* filters owned by the user.
* filters shared with a group that the user is a member of.
* filters shared with a private project that the user has *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for.
* filters shared with a public project.
* filters shared with the public.
*/
export async function main(auth: Jira, id: string, expand: string | undefined) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/filter/${id}/favourite`
);
for (const [k, v] of [["expand", expand]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
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 396 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Add filter as favorite
* Add a filter as a favorite for the user.
**[Permissions](#permissions) required:** Permission to access Jira, however, the user can only favorite:
* filters owned by the user.
* filters shared with a group that the user is a member of.
* filters shared with a private project that the user has *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for.
* filters shared with a public project.
* filters shared with the public.
*/
export async function main(auth: Jira, id: string, expand: string | undefined) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/filter/${id}/favourite`
);
for (const [k, v] of [["expand", expand]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
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 948 days ago