type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get available workflow capabilities
* Get the list of workflow capabilities for a specific workflow using either the workflow ID, or the project and issue type ID pair.
*/
export async function main(
auth: Jira,
workflowId: string | undefined,
projectId: string | undefined,
issueTypeId: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/workflows/capabilities`
);
for (const [k, v] of [
["workflowId", workflowId],
["projectId", projectId],
["issueTypeId", issueTypeId],
]) {
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;
};
/**
* Get available workflow capabilities
* Get the list of workflow capabilities for a specific workflow using either the workflow ID, or the project and issue type ID pair.
*/
export async function main(
auth: Jira,
workflowId: string | undefined,
projectId: string | undefined,
issueTypeId: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/workflows/capabilities`
);
for (const [k, v] of [
["workflowId", workflowId],
["projectId", projectId],
["issueTypeId", issueTypeId],
]) {
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