type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get user
* Returns a user.
Privacy controls are applied to the response based on the user's preferences. This could mean, for example, that the user's email address is hidden. See the [Profile visibility overview](https://developer.atlassian.com/cloud/jira/platform/profile-visibility/) for more details.
**[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
export async function main(
auth: Jira,
accountId: string | undefined,
username: string | undefined,
key: string | undefined,
expand: string | undefined
) {
const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/2/user`);
for (const [k, v] of [
["accountId", accountId],
["username", username],
["key", key],
["expand", expand],
]) {
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 327 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get user
* Returns a user.
Privacy controls are applied to the response based on the user's preferences. This could mean, for example, that the user's email address is hidden. See the [Profile visibility overview](https://developer.atlassian.com/cloud/jira/platform/profile-visibility/) for more details.
**[Permissions](#permissions) required:** *Browse users and groups* [global permission](https://confluence.atlassian.com/x/x4dKLg).
*/
export async function main(
auth: Jira,
accountId: string | undefined,
username: string | undefined,
key: string | undefined,
expand: string | undefined
) {
const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/2/user`);
for (const [k, v] of [
["accountId", accountId],
["username", username],
["key", key],
["expand", expand],
]) {
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 879 days ago