//native
/**
* Get Issue Picker Suggestions
* Suggest issues matching a text query, as Jira's own issue picker does: matches from the user's history and from `current_jql`. Useful to resolve a fragment of a title or key to an issue.
*/
export async function main(
auth: RT.Jira,
query: string | undefined,
current_jql: string | undefined,
current_issue_key: string | undefined,
current_project_id: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/3/issue/picker`
)
if (query != null && query !== "") {
url.searchParams.append("query", query)
}
if (current_jql != null && current_jql !== "") {
url.searchParams.append("currentJQL", current_jql)
}
if (current_issue_key != null && current_issue_key !== "") {
url.searchParams.append("currentIssueKey", current_issue_key)
}
if (current_project_id != null && current_project_id !== "") {
url.searchParams.append("currentProjectId", current_project_id)
}
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 8 days ago