/**
 * Generated by orval v8.3.0 🍺
 * Do not edit manually.
 * Mission Control API
 * OpenAPI spec version: 0.1.0
 */
import { useMutation } from "@tanstack/react-query";
import type {
  MutationFunction,
  QueryClient,
  UseMutationOptions,
  UseMutationResult,
} from "@tanstack/react-query";

import type { LLMErrorResponse, UserRead } from ".././model";

import { customFetch } from "../../mutator";

type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];

/**
 * Resolve caller identity from auth headers and return the canonical user profile. This endpoint does not accept a request body.
 * @summary Bootstrap Authenticated User Context
 */
export type bootstrapUserApiV1AuthBootstrapPostResponse200 = {
  data: UserRead;
  status: 200;
};

export type bootstrapUserApiV1AuthBootstrapPostResponse401 = {
  data: LLMErrorResponse;
  status: 401;
};

export type bootstrapUserApiV1AuthBootstrapPostResponseSuccess =
  bootstrapUserApiV1AuthBootstrapPostResponse200 & {
    headers: Headers;
  };
export type bootstrapUserApiV1AuthBootstrapPostResponseError =
  bootstrapUserApiV1AuthBootstrapPostResponse401 & {
    headers: Headers;
  };

export type bootstrapUserApiV1AuthBootstrapPostResponse =
  | bootstrapUserApiV1AuthBootstrapPostResponseSuccess
  | bootstrapUserApiV1AuthBootstrapPostResponseError;

export const getBootstrapUserApiV1AuthBootstrapPostUrl = () => {
  return `/api/v1/auth/bootstrap`;
};

export const bootstrapUserApiV1AuthBootstrapPost = async (
  options?: RequestInit,
): Promise<bootstrapUserApiV1AuthBootstrapPostResponse> => {
  return customFetch<bootstrapUserApiV1AuthBootstrapPostResponse>(
    getBootstrapUserApiV1AuthBootstrapPostUrl(),
    {
      ...options,
      method: "POST",
    },
  );
};

export const getBootstrapUserApiV1AuthBootstrapPostMutationOptions = <
  TError = LLMErrorResponse,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof bootstrapUserApiV1AuthBootstrapPost>>,
    TError,
    void,
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof bootstrapUserApiV1AuthBootstrapPost>>,
  TError,
  void,
  TContext
> => {
  const mutationKey = ["bootstrapUserApiV1AuthBootstrapPost"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof bootstrapUserApiV1AuthBootstrapPost>>,
    void
  > = () => {
    return bootstrapUserApiV1AuthBootstrapPost(requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type BootstrapUserApiV1AuthBootstrapPostMutationResult = NonNullable<
  Awaited<ReturnType<typeof bootstrapUserApiV1AuthBootstrapPost>>
>;

export type BootstrapUserApiV1AuthBootstrapPostMutationError = LLMErrorResponse;

/**
 * @summary Bootstrap Authenticated User Context
 */
export const useBootstrapUserApiV1AuthBootstrapPost = <
  TError = LLMErrorResponse,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof bootstrapUserApiV1AuthBootstrapPost>>,
      TError,
      void,
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof bootstrapUserApiV1AuthBootstrapPost>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getBootstrapUserApiV1AuthBootstrapPostMutationOptions(options),
    queryClient,
  );
};
