type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Find users for picker
* Returns a list of users whose attributes match the query term.
*/
export async function main(
auth: Jira,
query: string | undefined,
maxResults: string | undefined,
showAvatar: string | undefined,
exclude: string | undefined,
excludeAccountIds: string | undefined,
avatarSize: string | undefined,
excludeConnectUsers: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/user/picker`
);
for (const [k, v] of [
["query", query],
["maxResults", maxResults],
["showAvatar", showAvatar],
["exclude", exclude],
["excludeAccountIds", excludeAccountIds],
["avatarSize", avatarSize],
["excludeConnectUsers", excludeConnectUsers],
]) {
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;
};
/**
* Find users for picker
* Returns a list of users whose attributes match the query term.
*/
export async function main(
auth: Jira,
query: string | undefined,
maxResults: string | undefined,
showAvatar: string | undefined,
exclude: string | undefined,
excludeAccountIds: string | undefined,
avatarSize: string | undefined,
excludeConnectUsers: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/user/picker`
);
for (const [k, v] of [
["query", query],
["maxResults", maxResults],
["showAvatar", showAvatar],
["exclude", exclude],
["excludeAccountIds", excludeAccountIds],
["avatarSize", avatarSize],
["excludeConnectUsers", excludeConnectUsers],
]) {
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