/**
 * 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 {
  ApiAccountUsersListParams,
  ChangePassword,
  CustomUser,
  PaginatedCustomUserList,
  PatchedCustomUser,
} from "../models";

import { privateMutator } from "../../../privateClient";

// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497
type IfEquals<X, Y, A = X, B = never> =
  (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;

type WritableKeys<T> = {
  [P in keyof T]-?: IfEquals<
    { [Q in P]: T[P] },
    { -readonly [Q in P]: T[P] },
    P
  >;
}[keyof T];

type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
  k: infer I,
) => void
  ? I
  : never;
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;

type Writable<T> = Pick<T, WritableKeys<T>>;
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
  ? {
      [P in keyof Writable<T>]: T[P] extends object
        ? NonReadonly<NonNullable<T[P]>>
        : T[P];
    }
  : DistributeReadOnlyOverUnions<T>;

/**
 * Validates current password + Turnstile, stores pending_email, sends confirmation link to the new address and a notification to the old one.
 * @summary Request email address change
 */
export const apiAccountChangeEmailCreate = (signal?: AbortSignal) => {
  return privateMutator<void>({
    url: `/api/account/change-email/`,
    method: "POST",
    signal,
  });
};

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

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

export type ApiAccountChangeEmailCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountChangeEmailCreate>>
>;

export type ApiAccountChangeEmailCreateMutationError = void;

/**
 * @summary Request email address change
 */
export const useApiAccountChangeEmailCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountChangeEmailCreate>>,
      TError,
      void,
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountChangeEmailCreate>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getApiAccountChangeEmailCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Updates the username. Requires Turnstile. Limited to once per 30 days.
 * @summary Change username
 */
export const apiAccountChangeUsernameCreate = (signal?: AbortSignal) => {
  return privateMutator<void>({
    url: `/api/account/change-username/`,
    method: "POST",
    signal,
  });
};

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

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

export type ApiAccountChangeUsernameCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountChangeUsernameCreate>>
>;

export type ApiAccountChangeUsernameCreateMutationError = void;

/**
 * @summary Change username
 */
export const useApiAccountChangeUsernameCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountChangeUsernameCreate>>,
      TError,
      void,
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountChangeUsernameCreate>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getApiAccountChangeUsernameCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Verifies uid + token from the confirmation email, swaps email to pending_email.
 * @summary Confirm email address change via link
 */
export const apiAccountConfirmEmailChangeRetrieve = (
  uidb64: string,
  token: string,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/account/confirm-email-change/${uidb64}/${token}/`,
    method: "GET",
    signal,
  });
};

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

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

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

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

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

export type ApiAccountConfirmEmailChangeRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountConfirmEmailChangeRetrieve>>
>;
export type ApiAccountConfirmEmailChangeRetrieveQueryError = void;

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

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

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

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

/**
 * Soft-deletes the authenticated user's account after password confirmation. Clears auth cookies.
 * @summary Delete own account
 */
export const apiAccountDeleteCreate = (signal?: AbortSignal) => {
  return privateMutator<void>({
    url: `/api/account/delete/`,
    method: "POST",
    signal,
  });
};

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

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

export type ApiAccountDeleteCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountDeleteCreate>>
>;

export type ApiAccountDeleteCreateMutationError = void;

/**
 * @summary Delete own account
 */
export const useApiAccountDeleteCreate = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountDeleteCreate>>,
      TError,
      void,
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountDeleteCreate>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getApiAccountDeleteCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Change password for the authenticated user
 */
export const apiAccountPasswordChangeCreate = (
  changePassword: ChangePassword,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/account/password-change/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: changePassword,
    signal,
  });
};

export const getApiAccountPasswordChangeCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountPasswordChangeCreate>>,
    TError,
    { data: ChangePassword },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountPasswordChangeCreate>>,
  TError,
  { data: ChangePassword },
  TContext
> => {
  const mutationKey = ["apiAccountPasswordChangeCreate"];
  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 apiAccountPasswordChangeCreate>>,
    { data: ChangePassword }
  > = (props) => {
    const { data } = props ?? {};

    return apiAccountPasswordChangeCreate(data);
  };

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

export type ApiAccountPasswordChangeCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountPasswordChangeCreate>>
>;
export type ApiAccountPasswordChangeCreateMutationBody = ChangePassword;
export type ApiAccountPasswordChangeCreateMutationError = void;

/**
 * @summary Change password for the authenticated user
 */
export const useApiAccountPasswordChangeCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountPasswordChangeCreate>>,
      TError,
      { data: ChangePassword },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountPasswordChangeCreate>>,
  TError,
  { data: ChangePassword },
  TContext
> => {
  return useMutation(
    getApiAccountPasswordChangeCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Resends the verification email to the currently authenticated user. Limited to once per minute.
 * @summary Resend email verification
 */
export const apiAccountResendVerificationCreate = (signal?: AbortSignal) => {
  return privateMutator<void>({
    url: `/api/account/resend-verification/`,
    method: "POST",
    signal,
  });
};

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

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

export type ApiAccountResendVerificationCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountResendVerificationCreate>>
>;

export type ApiAccountResendVerificationCreateMutationError = void;

/**
 * @summary Resend email verification
 */
export const useApiAccountResendVerificationCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountResendVerificationCreate>>,
      TError,
      void,
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountResendVerificationCreate>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getApiAccountResendVerificationCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Returns details of the currently authenticated user based on JWT token or session.
 * @summary Get current authenticated user
 */
export const apiAccountUserMeRetrieve = (signal?: AbortSignal) => {
  return privateMutator<CustomUser>({
    url: `/api/account/user/me/`,
    method: "GET",
    signal,
  });
};

export const getApiAccountUserMeRetrieveQueryKey = () => {
  return [`/api/account/user/me/`] as const;
};

export const getApiAccountUserMeRetrieveQueryOptions = <
  TData = Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
  TError = void,
>(options?: {
  query?: Partial<
    UseQueryOptions<
      Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
      TError,
      TData
    >
  >;
}) => {
  const { query: queryOptions } = options ?? {};

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

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>
  > = ({ signal }) => apiAccountUserMeRetrieve(signal);

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

export type ApiAccountUserMeRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>
>;
export type ApiAccountUserMeRetrieveQueryError = void;

export function useApiAccountUserMeRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
  TError = void,
>(
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiAccountUserMeRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
  TError = void,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiAccountUserMeRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
  TError = void,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get current authenticated user
 */

export function useApiAccountUserMeRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
  TError = void,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUserMeRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getApiAccountUserMeRetrieveQueryOptions(options);

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

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

/**
 * Displays all users with filtering and ordering options. Requires authentication and appropriate role.
 * @summary List, retrieve, update, and delete users.
 */
export const apiAccountUsersList = (
  params?: ApiAccountUsersListParams,
  signal?: AbortSignal,
) => {
  return privateMutator<PaginatedCustomUserList>({
    url: `/api/account/users/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiAccountUsersListQueryKey = (
  params?: ApiAccountUsersListParams,
) => {
  return [`/api/account/users/`, ...(params ? [params] : [])] as const;
};

export const getApiAccountUsersListQueryOptions = <
  TData = Awaited<ReturnType<typeof apiAccountUsersList>>,
  TError = void,
>(
  params?: ApiAccountUsersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersList>>,
        TError,
        TData
      >
    >;
  },
) => {
  const { query: queryOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ?? getApiAccountUsersListQueryKey(params);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof apiAccountUsersList>>
  > = ({ signal }) => apiAccountUsersList(params, signal);

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

export type ApiAccountUsersListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountUsersList>>
>;
export type ApiAccountUsersListQueryError = void;

export function useApiAccountUsersList<
  TData = Awaited<ReturnType<typeof apiAccountUsersList>>,
  TError = void,
>(
  params: undefined | ApiAccountUsersListParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersList>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiAccountUsersList>>,
          TError,
          Awaited<ReturnType<typeof apiAccountUsersList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiAccountUsersList<
  TData = Awaited<ReturnType<typeof apiAccountUsersList>>,
  TError = void,
>(
  params?: ApiAccountUsersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersList>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiAccountUsersList>>,
          TError,
          Awaited<ReturnType<typeof apiAccountUsersList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiAccountUsersList<
  TData = Awaited<ReturnType<typeof apiAccountUsersList>>,
  TError = void,
>(
  params?: ApiAccountUsersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List, retrieve, update, and delete users.
 */

export function useApiAccountUsersList<
  TData = Awaited<ReturnType<typeof apiAccountUsersList>>,
  TError = void,
>(
  params?: ApiAccountUsersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getApiAccountUsersListQueryOptions(params, options);

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

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

/**
 * Displays all users with filtering and ordering options. Requires authentication and appropriate role.
 * @summary List, retrieve, update, and delete users.
 */
export const apiAccountUsersCreate = (
  customUser: NonReadonly<CustomUser>,
  signal?: AbortSignal,
) => {
  return privateMutator<CustomUser>({
    url: `/api/account/users/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: customUser,
    signal,
  });
};

export const getApiAccountUsersCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountUsersCreate>>,
    TError,
    { data: NonReadonly<CustomUser> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountUsersCreate>>,
  TError,
  { data: NonReadonly<CustomUser> },
  TContext
> => {
  const mutationKey = ["apiAccountUsersCreate"];
  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 apiAccountUsersCreate>>,
    { data: NonReadonly<CustomUser> }
  > = (props) => {
    const { data } = props ?? {};

    return apiAccountUsersCreate(data);
  };

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

export type ApiAccountUsersCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountUsersCreate>>
>;
export type ApiAccountUsersCreateMutationBody = NonReadonly<CustomUser>;
export type ApiAccountUsersCreateMutationError = void;

/**
 * @summary List, retrieve, update, and delete users.
 */
export const useApiAccountUsersCreate = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountUsersCreate>>,
      TError,
      { data: NonReadonly<CustomUser> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountUsersCreate>>,
  TError,
  { data: NonReadonly<CustomUser> },
  TContext
> => {
  return useMutation(
    getApiAccountUsersCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Displays all users with filtering and ordering options. Requires authentication and appropriate role.
 * @summary List, retrieve, update, and delete users.
 */
export const apiAccountUsersRetrieve = (id: number, signal?: AbortSignal) => {
  return privateMutator<CustomUser>({
    url: `/api/account/users/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiAccountUsersRetrieveQueryKey = (id: number) => {
  return [`/api/account/users/${id}/`] as const;
};

export const getApiAccountUsersRetrieveQueryOptions = <
  TData = Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
  TError = void,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
        TError,
        TData
      >
    >;
  },
) => {
  const { query: queryOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ?? getApiAccountUsersRetrieveQueryKey(id);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof apiAccountUsersRetrieve>>
  > = ({ signal }) => apiAccountUsersRetrieve(id, signal);

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

export type ApiAccountUsersRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountUsersRetrieve>>
>;
export type ApiAccountUsersRetrieveQueryError = void;

export function useApiAccountUsersRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
  TError = void,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiAccountUsersRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiAccountUsersRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
  TError = void,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiAccountUsersRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiAccountUsersRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
  TError = void,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List, retrieve, update, and delete users.
 */

export function useApiAccountUsersRetrieve<
  TData = Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
  TError = void,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiAccountUsersRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getApiAccountUsersRetrieveQueryOptions(id, options);

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

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

/**
 * Displays all users with filtering and ordering options. Requires authentication and appropriate role.
 * @summary List, retrieve, update, and delete users.
 */
export const apiAccountUsersUpdate = (
  id: number,
  customUser: NonReadonly<CustomUser>,
  signal?: AbortSignal,
) => {
  return privateMutator<CustomUser>({
    url: `/api/account/users/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: customUser,
    signal,
  });
};

export const getApiAccountUsersUpdateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountUsersUpdate>>,
    TError,
    { id: number; data: NonReadonly<CustomUser> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountUsersUpdate>>,
  TError,
  { id: number; data: NonReadonly<CustomUser> },
  TContext
> => {
  const mutationKey = ["apiAccountUsersUpdate"];
  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 apiAccountUsersUpdate>>,
    { id: number; data: NonReadonly<CustomUser> }
  > = (props) => {
    const { id, data } = props ?? {};

    return apiAccountUsersUpdate(id, data);
  };

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

export type ApiAccountUsersUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountUsersUpdate>>
>;
export type ApiAccountUsersUpdateMutationBody = NonReadonly<CustomUser>;
export type ApiAccountUsersUpdateMutationError = void;

/**
 * @summary List, retrieve, update, and delete users.
 */
export const useApiAccountUsersUpdate = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountUsersUpdate>>,
      TError,
      { id: number; data: NonReadonly<CustomUser> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountUsersUpdate>>,
  TError,
  { id: number; data: NonReadonly<CustomUser> },
  TContext
> => {
  return useMutation(
    getApiAccountUsersUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * Displays all users with filtering and ordering options. Requires authentication and appropriate role.
 * @summary List, retrieve, update, and delete users.
 */
export const apiAccountUsersPartialUpdate = (
  id: number,
  patchedCustomUser: NonReadonly<PatchedCustomUser>,
  signal?: AbortSignal,
) => {
  return privateMutator<CustomUser>({
    url: `/api/account/users/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedCustomUser,
    signal,
  });
};

export const getApiAccountUsersPartialUpdateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountUsersPartialUpdate>>,
    TError,
    { id: number; data: NonReadonly<PatchedCustomUser> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountUsersPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedCustomUser> },
  TContext
> => {
  const mutationKey = ["apiAccountUsersPartialUpdate"];
  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 apiAccountUsersPartialUpdate>>,
    { id: number; data: NonReadonly<PatchedCustomUser> }
  > = (props) => {
    const { id, data } = props ?? {};

    return apiAccountUsersPartialUpdate(id, data);
  };

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

export type ApiAccountUsersPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountUsersPartialUpdate>>
>;
export type ApiAccountUsersPartialUpdateMutationBody =
  NonReadonly<PatchedCustomUser>;
export type ApiAccountUsersPartialUpdateMutationError = void;

/**
 * @summary List, retrieve, update, and delete users.
 */
export const useApiAccountUsersPartialUpdate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountUsersPartialUpdate>>,
      TError,
      { id: number; data: NonReadonly<PatchedCustomUser> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountUsersPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedCustomUser> },
  TContext
> => {
  return useMutation(
    getApiAccountUsersPartialUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * Displays all users with filtering and ordering options. Requires authentication and appropriate role.
 * @summary List, retrieve, update, and delete users.
 */
export const apiAccountUsersDestroy = (id: number, signal?: AbortSignal) => {
  return privateMutator<CustomUser>({
    url: `/api/account/users/${id}/`,
    method: "DELETE",
    signal,
  });
};

export const getApiAccountUsersDestroyMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiAccountUsersDestroy>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiAccountUsersDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiAccountUsersDestroy"];
  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 apiAccountUsersDestroy>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiAccountUsersDestroy(id);
  };

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

export type ApiAccountUsersDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiAccountUsersDestroy>>
>;

export type ApiAccountUsersDestroyMutationError = void;

/**
 * @summary List, retrieve, update, and delete users.
 */
export const useApiAccountUsersDestroy = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiAccountUsersDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiAccountUsersDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiAccountUsersDestroyMutationOptions(options),
    queryClient,
  );
};
