export type UpdateApiRestAgile10EpicEpicIdOrKeyRankArgs = {epicIdOrKey: string, body: {rankAfterEpic?: string | undefined, rankBeforeEpic?: string | undefined, rankCustomFieldId?: number | undefined}}; export type UpdateApiRestAgile10EpicEpicIdOrKeyRankOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Rank epics * * PUT /rest/agile/1.0/epic/{epicIdOrKey}/rank * * Also accepts auth: OAuth2 */ export const updateApiRestAgile10EpicEpicIdOrKeyRank = async (args: UpdateApiRestAgile10EpicEpicIdOrKeyRankArgs, options?: UpdateApiRestAgile10EpicEpicIdOrKeyRankOptions) => { 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/epic/${encodeURIComponent(String(args.epicIdOrKey))}/rank${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };