//native
/**
* List Issue Comments
* List the comments on an issue, one page at a time (`startAt` / `maxResults` / `total` in the response). Comment bodies are Atlassian Document Format; set `render_body` to also get them as HTML.
*/
export async function main(
auth: RT.Jira,
issue_id_or_key: string,
order_by: "created" | "-created" | undefined,
render_body: boolean | undefined,
start_at: number | undefined,
max_results: number | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/3/issue/${issue_id_or_key}/comment`
)
if (order_by != null && order_by !== "") {
url.searchParams.append("orderBy", order_by)
}
if (start_at != null) {
url.searchParams.append("startAt", String(start_at))
}
if (max_results != null) {
url.searchParams.append("maxResults", String(max_results))
}
if (render_body) {
url.searchParams.append("expand", "renderedBody")
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 hours ago