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

import type {
  HTTPValidationError,
  OkResponse,
  UserRead,
  UserUpdate,
} from ".././model";

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

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

/**
 * Return the authenticated user's current profile payload.
 * @summary Get Me
 */
export type getMeApiV1UsersMeGetResponse200 = {
  data: UserRead;
  status: 200;
};

export type getMeApiV1UsersMeGetResponseSuccess =
  getMeApiV1UsersMeGetResponse200 & {
    headers: Headers;
  };
export type getMeApiV1UsersMeGetResponse = getMeApiV1UsersMeGetResponseSuccess;

export const getGetMeApiV1UsersMeGetUrl = () => {
  return `/api/v1/users/me`;
};

export const getMeApiV1UsersMeGet = async (
  options?: RequestInit,
): Promise<getMeApiV1UsersMeGetResponse> => {
  return customFetch<getMeApiV1UsersMeGetResponse>(
    getGetMeApiV1UsersMeGetUrl(),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetMeApiV1UsersMeGetQueryKey = () => {
  return [`/api/v1/users/me`] as const;
};

export const getGetMeApiV1UsersMeGetQueryOptions = <
  TData = Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
  TError = unknown,
>(options?: {
  query?: Partial<
    UseQueryOptions<
      Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
      TError,
      TData
    >
  >;
  request?: SecondParameter<typeof customFetch>;
}) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey = queryOptions?.queryKey ?? getGetMeApiV1UsersMeGetQueryKey();

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>
  > = ({ signal }) => getMeApiV1UsersMeGet({ signal, ...requestOptions });

  return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
    Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type GetMeApiV1UsersMeGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>
>;
export type GetMeApiV1UsersMeGetQueryError = unknown;

export function useGetMeApiV1UsersMeGet<
  TData = Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
  TError = unknown,
>(
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
          TError,
          Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetMeApiV1UsersMeGet<
  TData = Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
          TError,
          Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetMeApiV1UsersMeGet<
  TData = Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Me
 */

export function useGetMeApiV1UsersMeGet<
  TData = Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getMeApiV1UsersMeGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getGetMeApiV1UsersMeGetQueryOptions(options);

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Delete the authenticated account and any personal-only organizations.
 * @summary Delete Me
 */
export type deleteMeApiV1UsersMeDeleteResponse200 = {
  data: OkResponse;
  status: 200;
};

export type deleteMeApiV1UsersMeDeleteResponseSuccess =
  deleteMeApiV1UsersMeDeleteResponse200 & {
    headers: Headers;
  };
export type deleteMeApiV1UsersMeDeleteResponse =
  deleteMeApiV1UsersMeDeleteResponseSuccess;

export const getDeleteMeApiV1UsersMeDeleteUrl = () => {
  return `/api/v1/users/me`;
};

export const deleteMeApiV1UsersMeDelete = async (
  options?: RequestInit,
): Promise<deleteMeApiV1UsersMeDeleteResponse> => {
  return customFetch<deleteMeApiV1UsersMeDeleteResponse>(
    getDeleteMeApiV1UsersMeDeleteUrl(),
    {
      ...options,
      method: "DELETE",
    },
  );
};

export const getDeleteMeApiV1UsersMeDeleteMutationOptions = <
  TError = unknown,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof deleteMeApiV1UsersMeDelete>>,
    TError,
    void,
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof deleteMeApiV1UsersMeDelete>>,
  TError,
  void,
  TContext
> => {
  const mutationKey = ["deleteMeApiV1UsersMeDelete"];
  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 deleteMeApiV1UsersMeDelete>>,
    void
  > = () => {
    return deleteMeApiV1UsersMeDelete(requestOptions);
  };

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

export type DeleteMeApiV1UsersMeDeleteMutationResult = NonNullable<
  Awaited<ReturnType<typeof deleteMeApiV1UsersMeDelete>>
>;

export type DeleteMeApiV1UsersMeDeleteMutationError = unknown;

/**
 * @summary Delete Me
 */
export const useDeleteMeApiV1UsersMeDelete = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof deleteMeApiV1UsersMeDelete>>,
      TError,
      void,
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof deleteMeApiV1UsersMeDelete>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getDeleteMeApiV1UsersMeDeleteMutationOptions(options),
    queryClient,
  );
};
/**
 * Apply partial profile updates for the authenticated user.
 * @summary Update Me
 */
export type updateMeApiV1UsersMePatchResponse200 = {
  data: UserRead;
  status: 200;
};

export type updateMeApiV1UsersMePatchResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type updateMeApiV1UsersMePatchResponseSuccess =
  updateMeApiV1UsersMePatchResponse200 & {
    headers: Headers;
  };
export type updateMeApiV1UsersMePatchResponseError =
  updateMeApiV1UsersMePatchResponse422 & {
    headers: Headers;
  };

export type updateMeApiV1UsersMePatchResponse =
  | updateMeApiV1UsersMePatchResponseSuccess
  | updateMeApiV1UsersMePatchResponseError;

export const getUpdateMeApiV1UsersMePatchUrl = () => {
  return `/api/v1/users/me`;
};

export const updateMeApiV1UsersMePatch = async (
  userUpdate: UserUpdate,
  options?: RequestInit,
): Promise<updateMeApiV1UsersMePatchResponse> => {
  return customFetch<updateMeApiV1UsersMePatchResponse>(
    getUpdateMeApiV1UsersMePatchUrl(),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(userUpdate),
    },
  );
};

export const getUpdateMeApiV1UsersMePatchMutationOptions = <
  TError = HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof updateMeApiV1UsersMePatch>>,
    TError,
    { data: UserUpdate },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof updateMeApiV1UsersMePatch>>,
  TError,
  { data: UserUpdate },
  TContext
> => {
  const mutationKey = ["updateMeApiV1UsersMePatch"];
  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 updateMeApiV1UsersMePatch>>,
    { data: UserUpdate }
  > = (props) => {
    const { data } = props ?? {};

    return updateMeApiV1UsersMePatch(data, requestOptions);
  };

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

export type UpdateMeApiV1UsersMePatchMutationResult = NonNullable<
  Awaited<ReturnType<typeof updateMeApiV1UsersMePatch>>
>;
export type UpdateMeApiV1UsersMePatchMutationBody = UserUpdate;
export type UpdateMeApiV1UsersMePatchMutationError = HTTPValidationError;

/**
 * @summary Update Me
 */
export const useUpdateMeApiV1UsersMePatch = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof updateMeApiV1UsersMePatch>>,
      TError,
      { data: UserUpdate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof updateMeApiV1UsersMePatch>>,
  TError,
  { data: UserUpdate },
  TContext
> => {
  return useMutation(
    getUpdateMeApiV1UsersMePatchMutationOptions(options),
    queryClient,
  );
};
