//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Get user properties
* Returns the properties for a user as list of property keys. For more information
about user properties, see [Confluence entity properties](https://developer.atlassian.com/cloud/confluence/confluence-entity-properties/).
`Note`, these properties stored against a user are on a Confluence site level and not space/content level.
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
Permission to access the Confluence site ('Can use' global permission).
*/
export async function main(
auth: Confluence,
userId: string,
start: string | undefined,
limit: string | undefined
) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/user/${userId}/property`)
for (const [k, v] of [
['start', start],
['limit', limit]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago