export type GetApiApiV1GithubOauthCallbackArgs = {code?: string | undefined, state?: string | undefined, installation_id?: string | undefined, setup_action?: string | undefined}; export type GetApiApiV1GithubOauthCallbackOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GitHub OAuth callback * * GET /api/v1/github/oauth/callback */ export const getApiApiV1GithubOauthCallback = async (args: GetApiApiV1GithubOauthCallbackArgs, options: GetApiApiV1GithubOauthCallbackOptions) => { 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.installation_id != null) query.append("installation_id", String(args.installation_id)) if (args.setup_action != null) query.append("setup_action", String(args.setup_action)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/github/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 };