export type GetApiApiV1GitlabOauthCallbackArgs = {code?: string | undefined, state?: string | undefined, gitlab_instance_url?: string | undefined}; export type GetApiApiV1GitlabOauthCallbackOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GitLab OAuth callback * * GET /api/v1/gitlab/oauth/callback */ export const getApiApiV1GitlabOauthCallback = async (args: GetApiApiV1GitlabOauthCallbackArgs, options: GetApiApiV1GitlabOauthCallbackOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.code != null) query.append("code", String(args.code)) if (args.state != null) query.append("state", String(args.state)) if (args.gitlab_instance_url != null) query.append("gitlab_instance_url", String(args.gitlab_instance_url)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/gitlab/oauth/callback${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };