export type CreateApiRestAgile10SprintSprintIdIssueArgs = {sprintId: number, body: {issues?: Array | undefined, rankAfterIssue?: string | undefined, rankBeforeIssue?: string | undefined, rankCustomFieldId?: number | undefined}}; export type CreateApiRestAgile10SprintSprintIdIssueOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Move issues to sprint and rank * * POST /rest/agile/1.0/sprint/{sprintId}/issue * * Also accepts auth: OAuth2 */ export const createApiRestAgile10SprintSprintIdIssue = async (args: CreateApiRestAgile10SprintSprintIdIssueArgs, options?: CreateApiRestAgile10SprintSprintIdIssueOptions) => { const {baseUrl = "https://your-domain.atlassian.net", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/rest/agile/1.0/sprint/${encodeURIComponent(String(args.sprintId))}/issue${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };