/**
 * Generated by orval v8.8.0 🍺
 * Do not edit manually.
 * OpenAPI spec version: 0.0.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 {
  CustomTokenObtainPair,
  PasswordResetConfirm,
  PasswordResetRequest,
  UserRegistration,
} from "./models";

import { publicMutator } from "../../publicClient";

/**
 * Authenticate user and obtain JWT access and refresh tokens. You can use either email or username.
 * @summary Obtain JWT access and refresh tokens (cookie-based)
 */
export const apiAccountLoginCreate = (
  customTokenObtainPair: CustomTokenObtainPair,
  signal?: AbortSignal,
) => {
  return publicMutator<CustomTokenObtainPair>({
    url: `/api/account/login/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: customTokenObtainPair,
    signal,
  });
};

export const getApiAccountLoginCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountLoginCreate>>,
    TError,
    { data: CustomTokenObtainPair },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountLoginCreate>>,
  TError,
  { data: CustomTokenObtainPair },
  TContext
> => {
  const mutationKey = ["apiAccountLoginCreate"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof apiAccountLoginCreate>>,
    { data: CustomTokenObtainPair }
  > = (props) => {
    const { data } = props ?? {};

    return apiAccountLoginCreate(data);
  };

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

export type ApiAccountLoginCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountLoginCreate>>
>;
export type ApiAccountLoginCreateMutationBody = CustomTokenObtainPair;
export type ApiAccountLoginCreateMutationError = void;

/**
 * @summary Obtain JWT access and refresh tokens (cookie-based)
 */
export const useApiAccountLoginCreate = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountLoginCreate>>,
      TError,
      { data: CustomTokenObtainPair },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountLoginCreate>>,
  TError,
  { data: CustomTokenObtainPair },
  TContext
> => {
  return useMutation(
    getApiAccountLoginCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Logs out the user by deleting access and refresh token cookies.
 * @summary Logout user (delete access and refresh token cookies)
 */
export const apiAccountLogoutCreate = (signal?: AbortSignal) => {
  return publicMutator<void>({
    url: `/api/account/logout/`,
    method: "POST",
    signal,
  });
};

export const getApiAccountLogoutCreateMutationOptions = <
  TError = unknown,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
    TError,
    void,
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
  TError,
  void,
  TContext
> => {
  const mutationKey = ["apiAccountLogoutCreate"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

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

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

export type ApiAccountLogoutCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountLogoutCreate>>
>;

export type ApiAccountLogoutCreateMutationError = unknown;

/**
 * @summary Logout user (delete access and refresh token cookies)
 */
export const useApiAccountLogoutCreate = <TError = unknown, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
      TError,
      void,
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountLogoutCreate>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getApiAccountLogoutCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Request password reset by providing registered email. An email with instructions will be sent.
 * @summary Request password reset (send email)
 */
export const apiAccountPasswordResetCreate = (
  passwordResetRequest: PasswordResetRequest,
  signal?: AbortSignal,
) => {
  return publicMutator<void>({
    url: `/api/account/password-reset/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: passwordResetRequest,
    signal,
  });
};

export const getApiAccountPasswordResetCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
    TError,
    { data: PasswordResetRequest },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
  TError,
  { data: PasswordResetRequest },
  TContext
> => {
  const mutationKey = ["apiAccountPasswordResetCreate"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
    { data: PasswordResetRequest }
  > = (props) => {
    const { data } = props ?? {};

    return apiAccountPasswordResetCreate(data);
  };

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

export type ApiAccountPasswordResetCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>
>;
export type ApiAccountPasswordResetCreateMutationBody = PasswordResetRequest;
export type ApiAccountPasswordResetCreateMutationError = void;

/**
 * @summary Request password reset (send email)
 */
export const useApiAccountPasswordResetCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
      TError,
      { data: PasswordResetRequest },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountPasswordResetCreate>>,
  TError,
  { data: PasswordResetRequest },
  TContext
> => {
  return useMutation(
    getApiAccountPasswordResetCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Confirm password reset using token from email.
 * @summary Confirm password reset via token
 */
export const apiAccountPasswordResetConfirmCreate = (
  uidb64: string,
  token: string,
  passwordResetConfirm: PasswordResetConfirm,
  signal?: AbortSignal,
) => {
  return publicMutator<void>({
    url: `/api/account/password-reset-confirm/${uidb64}/${token}/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: passwordResetConfirm,
    signal,
  });
};

export const getApiAccountPasswordResetConfirmCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
    TError,
    { uidb64: string; token: string; data: PasswordResetConfirm },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
  TError,
  { uidb64: string; token: string; data: PasswordResetConfirm },
  TContext
> => {
  const mutationKey = ["apiAccountPasswordResetConfirmCreate"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
    { uidb64: string; token: string; data: PasswordResetConfirm }
  > = (props) => {
    const { uidb64, token, data } = props ?? {};

    return apiAccountPasswordResetConfirmCreate(uidb64, token, data);
  };

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

export type ApiAccountPasswordResetConfirmCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>
>;
export type ApiAccountPasswordResetConfirmCreateMutationBody =
  PasswordResetConfirm;
export type ApiAccountPasswordResetConfirmCreateMutationError = void;

/**
 * @summary Confirm password reset via token
 */
export const useApiAccountPasswordResetConfirmCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
      TError,
      { uidb64: string; token: string; data: PasswordResetConfirm },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountPasswordResetConfirmCreate>>,
  TError,
  { uidb64: string; token: string; data: PasswordResetConfirm },
  TContext
> => {
  return useMutation(
    getApiAccountPasswordResetConfirmCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Register a new user (company or individual). The user will receive an email with a verification link.
 * @summary Register a new user (company or individual)
 */
export const apiAccountRegisterCreate = (
  userRegistration: UserRegistration,
  signal?: AbortSignal,
) => {
  return publicMutator<UserRegistration>({
    url: `/api/account/register/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: userRegistration,
    signal,
  });
};

export const getApiAccountRegisterCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
    TError,
    { data: UserRegistration },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
  TError,
  { data: UserRegistration },
  TContext
> => {
  const mutationKey = ["apiAccountRegisterCreate"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
    { data: UserRegistration }
  > = (props) => {
    const { data } = props ?? {};

    return apiAccountRegisterCreate(data);
  };

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

export type ApiAccountRegisterCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountRegisterCreate>>
>;
export type ApiAccountRegisterCreateMutationBody = UserRegistration;
export type ApiAccountRegisterCreateMutationError = void;

/**
 * @summary Register a new user (company or individual)
 */
export const useApiAccountRegisterCreate = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
      TError,
      { data: UserRegistration },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountRegisterCreate>>,
  TError,
  { data: UserRegistration },
  TContext
> => {
  return useMutation(
    getApiAccountRegisterCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Refresh JWT access and refresh tokens using the refresh token stored in cookie.
 * @summary Refresh JWT token using cookie
 */
export const apiAccountTokenRefreshCreate = (signal?: AbortSignal) => {
  return publicMutator<void>({
    url: `/api/account/token/refresh/`,
    method: "POST",
    signal,
  });
};

export const getApiAccountTokenRefreshCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
    TError,
    void,
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
  TError,
  void,
  TContext
> => {
  const mutationKey = ["apiAccountTokenRefreshCreate"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

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

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

export type ApiAccountTokenRefreshCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>
>;

export type ApiAccountTokenRefreshCreateMutationError = void;

/**
 * @summary Refresh JWT token using cookie
 */
export const useApiAccountTokenRefreshCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
      TError,
      void,
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountTokenRefreshCreate>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getApiAccountTokenRefreshCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Verify user email using the link with uid and token.
 * @summary Verify user email via link
 */
export const apiAccountVerifyEmailRetrieve = (
  uidb64: string,
  token: string,
  signal?: AbortSignal,
) => {
  return publicMutator<void>({
    url: `/api/account/verify-email/${uidb64}/${token}/`,
    method: "GET",
    signal,
  });
};

export const getApiAccountVerifyEmailRetrieveQueryKey = (
  uidb64: string,
  token: string,
) => {
  return [`/api/account/verify-email/${uidb64}/${token}/`] as const;
};

export const getApiAccountVerifyEmailRetrieveQueryOptions = <
  TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
  TError = void,
>(
  uidb64: string,
  token: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
        TError,
        TData
      >
    >;
  },
) => {
  const { query: queryOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getApiAccountVerifyEmailRetrieveQueryKey(uidb64, token);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
  > = ({ signal }) => apiAccountVerifyEmailRetrieve(uidb64, token, signal);

  return {
    queryKey,
    queryFn,
    enabled: !!(uidb64 && token),
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type ApiAccountVerifyEmailRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
>;
export type ApiAccountVerifyEmailRetrieveQueryError = void;

export function useApiAccountVerifyEmailRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
  TError = void,
>(
  uidb64: string,
  token: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiAccountVerifyEmailRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
  TError = void,
>(
  uidb64: string,
  token: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiAccountVerifyEmailRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
  TError = void,
>(
  uidb64: string,
  token: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Verify user email via link
 */

export function useApiAccountVerifyEmailRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
  TError = void,
>(
  uidb64: string,
  token: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountVerifyEmailRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getApiAccountVerifyEmailRetrieveQueryOptions(
    uidb64,
    token,
    options,
  );

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

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