/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * MBHS
 * Multidimensional Behavioral Health Screen
 * OpenAPI spec version: 1.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 {
  ForgotPasswordDTO,
  Message,
  RefreshTokenDTO,
  RefreshTokenResponseModel,
  ResendVerificationDTO,
  ResetPasswordDTO,
  SendOTPDTO,
  SocialLoginDTO,
  UserLoginDTO,
  UserLoginResponseModel,
  UserRegisterDTO,
  UserRegisterResponseModel,
  ValidateTokenDTO,
  VerifyOTPDTO,
} from "../generated.schemas";

import { customInstance } from "../../../config/axios";

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

export const loginControllerLoginV1 = (
  userLoginDTO: UserLoginDTO,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`username`, userLoginDTO.username);
  formUrlEncoded.append(`password`, userLoginDTO.password);
  formUrlEncoded.append(`device_name`, userLoginDTO.device_name);
  formUrlEncoded.append(`device_type`, userLoginDTO.device_type);
  formUrlEncoded.append(`device_id`, userLoginDTO.device_id);
  if (userLoginDTO.device_token !== undefined) {
    formUrlEncoded.append(`device_token`, userLoginDTO.device_token);
  }

  return customInstance<UserLoginResponseModel>(
    {
      url: `/v1/login`,
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
      signal,
    },
    options,
  );
};

export const getLoginControllerLoginV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof loginControllerLoginV1>>,
    TError,
    { data: UserLoginDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof loginControllerLoginV1>>,
  TError,
  { data: UserLoginDTO },
  TContext
> => {
  const mutationKey = ["loginControllerLoginV1"];
  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 loginControllerLoginV1>>,
    { data: UserLoginDTO }
  > = (props) => {
    const { data } = props ?? {};

    return loginControllerLoginV1(data, requestOptions);
  };

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

export type LoginControllerLoginV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof loginControllerLoginV1>>
>;
export type LoginControllerLoginV1MutationBody = UserLoginDTO;
export type LoginControllerLoginV1MutationError = Message;

export const useLoginControllerLoginV1 = <TError = Message, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof loginControllerLoginV1>>,
      TError,
      { data: UserLoginDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof loginControllerLoginV1>>,
  TError,
  { data: UserLoginDTO },
  TContext
> => {
  const mutationOptions = getLoginControllerLoginV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const loginControllerSocialLoginV1 = (
  socialLoginDTO: SocialLoginDTO,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`social_type`, socialLoginDTO.social_type.toString());
  if (socialLoginDTO.name !== undefined) {
    formUrlEncoded.append(`name`, socialLoginDTO.name);
  }
  formUrlEncoded.append(`token`, socialLoginDTO.token);
  formUrlEncoded.append(`device_name`, socialLoginDTO.device_name);
  formUrlEncoded.append(`device_type`, socialLoginDTO.device_type);
  formUrlEncoded.append(`device_id`, socialLoginDTO.device_id);
  if (socialLoginDTO.device_token !== undefined) {
    formUrlEncoded.append(`device_token`, socialLoginDTO.device_token);
  }

  return customInstance<UserLoginResponseModel>(
    {
      url: `/v1/social-login`,
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
      signal,
    },
    options,
  );
};

export const getLoginControllerSocialLoginV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof loginControllerSocialLoginV1>>,
    TError,
    { data: SocialLoginDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof loginControllerSocialLoginV1>>,
  TError,
  { data: SocialLoginDTO },
  TContext
> => {
  const mutationKey = ["loginControllerSocialLoginV1"];
  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 loginControllerSocialLoginV1>>,
    { data: SocialLoginDTO }
  > = (props) => {
    const { data } = props ?? {};

    return loginControllerSocialLoginV1(data, requestOptions);
  };

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

export type LoginControllerSocialLoginV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof loginControllerSocialLoginV1>>
>;
export type LoginControllerSocialLoginV1MutationBody = SocialLoginDTO;
export type LoginControllerSocialLoginV1MutationError = Message;

export const useLoginControllerSocialLoginV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof loginControllerSocialLoginV1>>,
      TError,
      { data: SocialLoginDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof loginControllerSocialLoginV1>>,
  TError,
  { data: SocialLoginDTO },
  TContext
> => {
  const mutationOptions =
    getLoginControllerSocialLoginV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const loginControllerLogoutV1 = (
  options?: SecondParameter<typeof customInstance>,
) => {
  return customInstance<void>({ url: `/v1/logout`, method: "DELETE" }, options);
};

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

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

export type LoginControllerLogoutV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof loginControllerLogoutV1>>
>;

export type LoginControllerLogoutV1MutationError = Message;

export const useLoginControllerLogoutV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof loginControllerLogoutV1>>,
      TError,
      void,
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof loginControllerLogoutV1>>,
  TError,
  void,
  TContext
> => {
  const mutationOptions = getLoginControllerLogoutV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const loginControllerPastLogoutV1 = (
  options?: SecondParameter<typeof customInstance>,
) => {
  return customInstance<void>(
    { url: `/v1/past/logout`, method: "DELETE" },
    options,
  );
};

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

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

export type LoginControllerPastLogoutV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof loginControllerPastLogoutV1>>
>;

export type LoginControllerPastLogoutV1MutationError = Message;

export const useLoginControllerPastLogoutV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof loginControllerPastLogoutV1>>,
      TError,
      void,
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof loginControllerPastLogoutV1>>,
  TError,
  void,
  TContext
> => {
  const mutationOptions =
    getLoginControllerPastLogoutV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const loginControllerTokenRefreshV1 = (
  refreshTokenDTO: RefreshTokenDTO,
  options?: SecondParameter<typeof customInstance>,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`device_name`, refreshTokenDTO.device_name);
  formUrlEncoded.append(`device_type`, refreshTokenDTO.device_type);
  formUrlEncoded.append(`device_id`, refreshTokenDTO.device_id);
  if (refreshTokenDTO.device_token !== undefined) {
    formUrlEncoded.append(`device_token`, refreshTokenDTO.device_token);
  }

  return customInstance<RefreshTokenResponseModel>(
    {
      url: `/v1/token/refresh`,
      method: "PUT",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
    },
    options,
  );
};

export const getLoginControllerTokenRefreshV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof loginControllerTokenRefreshV1>>,
    TError,
    { data: RefreshTokenDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof loginControllerTokenRefreshV1>>,
  TError,
  { data: RefreshTokenDTO },
  TContext
> => {
  const mutationKey = ["loginControllerTokenRefreshV1"];
  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 loginControllerTokenRefreshV1>>,
    { data: RefreshTokenDTO }
  > = (props) => {
    const { data } = props ?? {};

    return loginControllerTokenRefreshV1(data, requestOptions);
  };

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

export type LoginControllerTokenRefreshV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof loginControllerTokenRefreshV1>>
>;
export type LoginControllerTokenRefreshV1MutationBody = RefreshTokenDTO;
export type LoginControllerTokenRefreshV1MutationError = Message;

export const useLoginControllerTokenRefreshV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof loginControllerTokenRefreshV1>>,
      TError,
      { data: RefreshTokenDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof loginControllerTokenRefreshV1>>,
  TError,
  { data: RefreshTokenDTO },
  TContext
> => {
  const mutationOptions =
    getLoginControllerTokenRefreshV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const registerControllerRegisterV1 = (
  userRegisterDTO: UserRegisterDTO,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`password`, userRegisterDTO.password);
  if (userRegisterDTO.isd_code !== undefined) {
    formUrlEncoded.append(`isd_code`, userRegisterDTO.isd_code);
  }
  if (userRegisterDTO.mobile !== undefined) {
    formUrlEncoded.append(`mobile`, userRegisterDTO.mobile);
  }
  formUrlEncoded.append(`role`, userRegisterDTO.role);
  formUrlEncoded.append(`name`, userRegisterDTO.name);
  formUrlEncoded.append(`username`, userRegisterDTO.username);
  formUrlEncoded.append(`email`, userRegisterDTO.email);
  formUrlEncoded.append(`device_name`, userRegisterDTO.device_name);
  formUrlEncoded.append(`device_type`, userRegisterDTO.device_type);
  formUrlEncoded.append(`device_id`, userRegisterDTO.device_id);
  if (userRegisterDTO.device_token !== undefined) {
    formUrlEncoded.append(`device_token`, userRegisterDTO.device_token);
  }

  return customInstance<UserRegisterResponseModel>(
    {
      url: `/v1/register`,
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
      signal,
    },
    options,
  );
};

export const getRegisterControllerRegisterV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof registerControllerRegisterV1>>,
    TError,
    { data: UserRegisterDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof registerControllerRegisterV1>>,
  TError,
  { data: UserRegisterDTO },
  TContext
> => {
  const mutationKey = ["registerControllerRegisterV1"];
  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 registerControllerRegisterV1>>,
    { data: UserRegisterDTO }
  > = (props) => {
    const { data } = props ?? {};

    return registerControllerRegisterV1(data, requestOptions);
  };

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

export type RegisterControllerRegisterV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof registerControllerRegisterV1>>
>;
export type RegisterControllerRegisterV1MutationBody = UserRegisterDTO;
export type RegisterControllerRegisterV1MutationError = Message;

export const useRegisterControllerRegisterV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof registerControllerRegisterV1>>,
      TError,
      { data: UserRegisterDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof registerControllerRegisterV1>>,
  TError,
  { data: UserRegisterDTO },
  TContext
> => {
  const mutationOptions =
    getRegisterControllerRegisterV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const forgotPasswordControllerForgotPasswordV1 = (
  forgotPasswordDTO: ForgotPasswordDTO,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`email`, forgotPasswordDTO.email);

  return customInstance<Message>(
    {
      url: `/v1/password/email`,
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
      signal,
    },
    options,
  );
};

export const getForgotPasswordControllerForgotPasswordV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof forgotPasswordControllerForgotPasswordV1>>,
    TError,
    { data: ForgotPasswordDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof forgotPasswordControllerForgotPasswordV1>>,
  TError,
  { data: ForgotPasswordDTO },
  TContext
> => {
  const mutationKey = ["forgotPasswordControllerForgotPasswordV1"];
  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 forgotPasswordControllerForgotPasswordV1>>,
    { data: ForgotPasswordDTO }
  > = (props) => {
    const { data } = props ?? {};

    return forgotPasswordControllerForgotPasswordV1(data, requestOptions);
  };

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

export type ForgotPasswordControllerForgotPasswordV1MutationResult =
  NonNullable<
    Awaited<ReturnType<typeof forgotPasswordControllerForgotPasswordV1>>
  >;
export type ForgotPasswordControllerForgotPasswordV1MutationBody =
  ForgotPasswordDTO;
export type ForgotPasswordControllerForgotPasswordV1MutationError = Message;

export const useForgotPasswordControllerForgotPasswordV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof forgotPasswordControllerForgotPasswordV1>>,
      TError,
      { data: ForgotPasswordDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof forgotPasswordControllerForgotPasswordV1>>,
  TError,
  { data: ForgotPasswordDTO },
  TContext
> => {
  const mutationOptions =
    getForgotPasswordControllerForgotPasswordV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const forgotPasswordControllerValidateTokenV1 = (
  validateTokenDTO: ValidateTokenDTO,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`token`, validateTokenDTO.token);

  return customInstance<void>(
    {
      url: `/v1/password/validate`,
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
      signal,
    },
    options,
  );
};

export const getForgotPasswordControllerValidateTokenV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof forgotPasswordControllerValidateTokenV1>>,
    TError,
    { data: ValidateTokenDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof forgotPasswordControllerValidateTokenV1>>,
  TError,
  { data: ValidateTokenDTO },
  TContext
> => {
  const mutationKey = ["forgotPasswordControllerValidateTokenV1"];
  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 forgotPasswordControllerValidateTokenV1>>,
    { data: ValidateTokenDTO }
  > = (props) => {
    const { data } = props ?? {};

    return forgotPasswordControllerValidateTokenV1(data, requestOptions);
  };

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

export type ForgotPasswordControllerValidateTokenV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof forgotPasswordControllerValidateTokenV1>>
>;
export type ForgotPasswordControllerValidateTokenV1MutationBody =
  ValidateTokenDTO;
export type ForgotPasswordControllerValidateTokenV1MutationError = Message;

export const useForgotPasswordControllerValidateTokenV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof forgotPasswordControllerValidateTokenV1>>,
      TError,
      { data: ValidateTokenDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof forgotPasswordControllerValidateTokenV1>>,
  TError,
  { data: ValidateTokenDTO },
  TContext
> => {
  const mutationOptions =
    getForgotPasswordControllerValidateTokenV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const forgotPasswordControllerResetPasswordV1 = (
  resetPasswordDTO: ResetPasswordDTO,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`token`, resetPasswordDTO.token);
  formUrlEncoded.append(`password`, resetPasswordDTO.password);
  if (resetPasswordDTO.confirm_password !== undefined) {
    formUrlEncoded.append(
      `confirm_password`,
      resetPasswordDTO.confirm_password,
    );
  }

  return customInstance<Message>(
    {
      url: `/v1/password/reset`,
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
      signal,
    },
    options,
  );
};

export const getForgotPasswordControllerResetPasswordV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof forgotPasswordControllerResetPasswordV1>>,
    TError,
    { data: ResetPasswordDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof forgotPasswordControllerResetPasswordV1>>,
  TError,
  { data: ResetPasswordDTO },
  TContext
> => {
  const mutationKey = ["forgotPasswordControllerResetPasswordV1"];
  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 forgotPasswordControllerResetPasswordV1>>,
    { data: ResetPasswordDTO }
  > = (props) => {
    const { data } = props ?? {};

    return forgotPasswordControllerResetPasswordV1(data, requestOptions);
  };

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

export type ForgotPasswordControllerResetPasswordV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof forgotPasswordControllerResetPasswordV1>>
>;
export type ForgotPasswordControllerResetPasswordV1MutationBody =
  ResetPasswordDTO;
export type ForgotPasswordControllerResetPasswordV1MutationError = Message;

export const useForgotPasswordControllerResetPasswordV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof forgotPasswordControllerResetPasswordV1>>,
      TError,
      { data: ResetPasswordDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof forgotPasswordControllerResetPasswordV1>>,
  TError,
  { data: ResetPasswordDTO },
  TContext
> => {
  const mutationOptions =
    getForgotPasswordControllerResetPasswordV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const otpControllerSendOTPV1 = (
  sendOTPDTO: SendOTPDTO,
  options?: SecondParameter<typeof customInstance>,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`verification_for`, sendOTPDTO.verification_for);
  if (sendOTPDTO.email !== undefined) {
    formUrlEncoded.append(`email`, sendOTPDTO.email);
  }
  if (sendOTPDTO.isd_code !== undefined) {
    formUrlEncoded.append(`isd_code`, sendOTPDTO.isd_code);
  }
  if (sendOTPDTO.mobile !== undefined) {
    formUrlEncoded.append(`mobile`, sendOTPDTO.mobile);
  }

  return customInstance<Message>(
    {
      url: `/v1/send-otp`,
      method: "PATCH",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
    },
    options,
  );
};

export const getOtpControllerSendOTPV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof otpControllerSendOTPV1>>,
    TError,
    { data: SendOTPDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof otpControllerSendOTPV1>>,
  TError,
  { data: SendOTPDTO },
  TContext
> => {
  const mutationKey = ["otpControllerSendOTPV1"];
  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 otpControllerSendOTPV1>>,
    { data: SendOTPDTO }
  > = (props) => {
    const { data } = props ?? {};

    return otpControllerSendOTPV1(data, requestOptions);
  };

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

export type OtpControllerSendOTPV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof otpControllerSendOTPV1>>
>;
export type OtpControllerSendOTPV1MutationBody = SendOTPDTO;
export type OtpControllerSendOTPV1MutationError = Message;

export const useOtpControllerSendOTPV1 = <TError = Message, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof otpControllerSendOTPV1>>,
      TError,
      { data: SendOTPDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof otpControllerSendOTPV1>>,
  TError,
  { data: SendOTPDTO },
  TContext
> => {
  const mutationOptions = getOtpControllerSendOTPV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
export const otpControllerVerifyOTPV1 = (
  verifyOTPDTO: VerifyOTPDTO,
  options?: SecondParameter<typeof customInstance>,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`verification_for`, verifyOTPDTO.verification_for);
  if (verifyOTPDTO.email !== undefined) {
    formUrlEncoded.append(`email`, verifyOTPDTO.email);
  }
  if (verifyOTPDTO.isd_code !== undefined) {
    formUrlEncoded.append(`isd_code`, verifyOTPDTO.isd_code);
  }
  if (verifyOTPDTO.mobile !== undefined) {
    formUrlEncoded.append(`mobile`, verifyOTPDTO.mobile);
  }
  formUrlEncoded.append(`otp`, verifyOTPDTO.otp);

  return customInstance<Message>(
    {
      url: `/v1/verify-otp`,
      method: "PATCH",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
    },
    options,
  );
};

export const getOtpControllerVerifyOTPV1MutationOptions = <
  TError = Message,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof otpControllerVerifyOTPV1>>,
    TError,
    { data: VerifyOTPDTO },
    TContext
  >;
  request?: SecondParameter<typeof customInstance>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof otpControllerVerifyOTPV1>>,
  TError,
  { data: VerifyOTPDTO },
  TContext
> => {
  const mutationKey = ["otpControllerVerifyOTPV1"];
  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 otpControllerVerifyOTPV1>>,
    { data: VerifyOTPDTO }
  > = (props) => {
    const { data } = props ?? {};

    return otpControllerVerifyOTPV1(data, requestOptions);
  };

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

export type OtpControllerVerifyOTPV1MutationResult = NonNullable<
  Awaited<ReturnType<typeof otpControllerVerifyOTPV1>>
>;
export type OtpControllerVerifyOTPV1MutationBody = VerifyOTPDTO;
export type OtpControllerVerifyOTPV1MutationError = Message;

export const useOtpControllerVerifyOTPV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof otpControllerVerifyOTPV1>>,
      TError,
      { data: VerifyOTPDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof otpControllerVerifyOTPV1>>,
  TError,
  { data: VerifyOTPDTO },
  TContext
> => {
  const mutationOptions = getOtpControllerVerifyOTPV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * @summary Verifies a user's email address using the token from the verification link.
 */
export const verifyEmailControllerVerifyEmailV1 = (
  token: string,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  return customInstance<void>(
    { url: `/v1/verify-email/${token}`, method: "GET", signal },
    options,
  );
};

export const getVerifyEmailControllerVerifyEmailV1QueryKey = (
  token?: string,
) => {
  return [`/v1/verify-email/${token}`] as const;
};

export const getVerifyEmailControllerVerifyEmailV1QueryOptions = <
  TData = Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
  TError = Message,
>(
  token: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customInstance>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getVerifyEmailControllerVerifyEmailV1QueryKey(token);

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

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

export type VerifyEmailControllerVerifyEmailV1QueryResult = NonNullable<
  Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>
>;
export type VerifyEmailControllerVerifyEmailV1QueryError = Message;

export function useVerifyEmailControllerVerifyEmailV1<
  TData = Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
  TError = Message,
>(
  token: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
          TError,
          Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useVerifyEmailControllerVerifyEmailV1<
  TData = Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
  TError = Message,
>(
  token: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
          TError,
          Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useVerifyEmailControllerVerifyEmailV1<
  TData = Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
  TError = Message,
>(
  token: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Verifies a user's email address using the token from the verification link.
 */

export function useVerifyEmailControllerVerifyEmailV1<
  TData = Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
  TError = Message,
>(
  token: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof verifyEmailControllerVerifyEmailV1>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getVerifyEmailControllerVerifyEmailV1QueryOptions(
    token,
    options,
  );

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * @summary Resends the verification email to the user.
 */
export const verifyEmailControllerResendVerificationEmailV1 = (
  resendVerificationDTO: ResendVerificationDTO,
  options?: SecondParameter<typeof customInstance>,
  signal?: AbortSignal,
) => {
  const formUrlEncoded = new URLSearchParams();
  formUrlEncoded.append(`email`, resendVerificationDTO.email);

  return customInstance<void>(
    {
      url: `/v1/verify-email/resend`,
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      data: formUrlEncoded,
      signal,
    },
    options,
  );
};

export const getVerifyEmailControllerResendVerificationEmailV1MutationOptions =
  <TError = Message, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof verifyEmailControllerResendVerificationEmailV1>
      >,
      TError,
      { data: ResendVerificationDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  }): UseMutationOptions<
    Awaited<ReturnType<typeof verifyEmailControllerResendVerificationEmailV1>>,
    TError,
    { data: ResendVerificationDTO },
    TContext
  > => {
    const mutationKey = ["verifyEmailControllerResendVerificationEmailV1"];
    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 verifyEmailControllerResendVerificationEmailV1>
      >,
      { data: ResendVerificationDTO }
    > = (props) => {
      const { data } = props ?? {};

      return verifyEmailControllerResendVerificationEmailV1(
        data,
        requestOptions,
      );
    };

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

export type VerifyEmailControllerResendVerificationEmailV1MutationResult =
  NonNullable<
    Awaited<ReturnType<typeof verifyEmailControllerResendVerificationEmailV1>>
  >;
export type VerifyEmailControllerResendVerificationEmailV1MutationBody =
  ResendVerificationDTO;
export type VerifyEmailControllerResendVerificationEmailV1MutationError =
  Message;

/**
 * @summary Resends the verification email to the user.
 */
export const useVerifyEmailControllerResendVerificationEmailV1 = <
  TError = Message,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof verifyEmailControllerResendVerificationEmailV1>
      >,
      TError,
      { data: ResendVerificationDTO },
      TContext
    >;
    request?: SecondParameter<typeof customInstance>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof verifyEmailControllerResendVerificationEmailV1>>,
  TError,
  { data: ResendVerificationDTO },
  TContext
> => {
  const mutationOptions =
    getVerifyEmailControllerResendVerificationEmailV1MutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
