type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get avatar image by type
* Returns the default project or issue type avatar image.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:** None.
*/
export async function main(
auth: Jira,
type: "issuetype" | "project",
size: "xsmall" | "small" | "medium" | "large" | "xlarge" | undefined,
format: "png" | "svg" | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/universal_avatar/view/type/${type}`
);
for (const [k, v] of [
["size", size],
["format", format],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
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;
};
/**
* Get avatar image by type
* Returns the default project or issue type avatar image.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:** None.
*/
export async function main(
auth: Jira,
type: "issuetype" | "project",
size: "xsmall" | "small" | "medium" | "large" | "xlarge" | undefined,
format: "png" | "svg" | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/universal_avatar/view/type/${type}`
);
for (const [k, v] of [
["size", size],
["format", format],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
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