/**
 * 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 { UserRead } from ".././model";

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

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

/**
 * Return the authenticated user profile from token claims.
 * @summary Bootstrap User
 */
export type bootstrapUserApiV1AuthBootstrapPostResponse200 = {
  data: UserRead;
  status: 200;
};

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

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 = unknown,
  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 = unknown;

/**
 * @summary Bootstrap User
 */
export const useBootstrapUserApiV1AuthBootstrapPost = <
  TError = unknown,
  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,
  );
};
