/**
 * 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 {
  ApiCommerceAdminWishlistsListParams,
  ApiCommerceRefundsListParams,
  Category,
  DiscountCode,
  PaginatedRefundList,
  PaginatedWishlistList,
  PatchedCategory,
  PatchedDiscountCode,
  PatchedProduct,
  PatchedProductImage,
  PatchedRefund,
  PatchedWishlist,
  Product,
  ProductImage,
  Refund,
  Wishlist,
} 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>;

/**
 * Admin-only wishlist management - can view and modify any user's wishlist
 * @summary List all wishlists (admin)
 */
export const apiCommerceAdminWishlistsList = (
  params?: ApiCommerceAdminWishlistsListParams,
  signal?: AbortSignal,
) => {
  return privateMutator<PaginatedWishlistList>({
    url: `/api/commerce/admin/wishlists/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiCommerceAdminWishlistsListQueryKey = (
  params?: ApiCommerceAdminWishlistsListParams,
) => {
  return [
    `/api/commerce/admin/wishlists/`,
    ...(params ? [params] : []),
  ] as const;
};

export const getApiCommerceAdminWishlistsListQueryOptions = <
  TData = Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
  TError = unknown,
>(
  params?: ApiCommerceAdminWishlistsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
        TError,
        TData
      >
    >;
  },
) => {
  const { query: queryOptions } = options ?? {};

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

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

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

export type ApiCommerceAdminWishlistsListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>
>;
export type ApiCommerceAdminWishlistsListQueryError = unknown;

export function useApiCommerceAdminWishlistsList<
  TData = Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
  TError = unknown,
>(
  params: undefined | ApiCommerceAdminWishlistsListParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceAdminWishlistsList<
  TData = Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
  TError = unknown,
>(
  params?: ApiCommerceAdminWishlistsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceAdminWishlistsList<
  TData = Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
  TError = unknown,
>(
  params?: ApiCommerceAdminWishlistsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List all wishlists (admin)
 */

export function useApiCommerceAdminWishlistsList<
  TData = Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
  TError = unknown,
>(
  params?: ApiCommerceAdminWishlistsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAdminWishlistsList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getApiCommerceAdminWishlistsListQueryOptions(
    params,
    options,
  );

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

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

/**
 * Admin-only wishlist management - can view and modify any user's wishlist
 * @summary Get wishlist by ID (admin)
 */
export const apiCommerceAdminWishlistsRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<Wishlist>({
    url: `/api/commerce/admin/wishlists/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiCommerceAdminWishlistsRetrieveQueryKey = (id: number) => {
  return [`/api/commerce/admin/wishlists/${id}/`] as const;
};

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

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

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

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

export type ApiCommerceAdminWishlistsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>
>;
export type ApiCommerceAdminWishlistsRetrieveQueryError = unknown;

export function useApiCommerceAdminWishlistsRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>,
  TError = unknown,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceAdminWishlistsRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceAdminWishlistsRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAdminWishlistsRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get wishlist by ID (admin)
 */

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

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

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

/**
 * Admin-only wishlist management - can view and modify any user's wishlist
 * @summary Update wishlist (admin)
 */
export const apiCommerceAdminWishlistsUpdate = (
  id: number,
  wishlist: NonReadonly<Wishlist>,
  signal?: AbortSignal,
) => {
  return privateMutator<Wishlist>({
    url: `/api/commerce/admin/wishlists/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: wishlist,
    signal,
  });
};

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

    return apiCommerceAdminWishlistsUpdate(id, data);
  };

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

export type ApiCommerceAdminWishlistsUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceAdminWishlistsUpdate>>
>;
export type ApiCommerceAdminWishlistsUpdateMutationBody = NonReadonly<Wishlist>;
export type ApiCommerceAdminWishlistsUpdateMutationError = unknown;

/**
 * @summary Update wishlist (admin)
 */
export const useApiCommerceAdminWishlistsUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceAdminWishlistsUpdate>>,
      TError,
      { id: number; data: NonReadonly<Wishlist> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceAdminWishlistsUpdate>>,
  TError,
  { id: number; data: NonReadonly<Wishlist> },
  TContext
> => {
  return useMutation(
    getApiCommerceAdminWishlistsUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * Admin-only wishlist management - can view and modify any user's wishlist
 * @summary Partially update wishlist (admin)
 */
export const apiCommerceAdminWishlistsPartialUpdate = (
  id: number,
  patchedWishlist: NonReadonly<PatchedWishlist>,
  signal?: AbortSignal,
) => {
  return privateMutator<Wishlist>({
    url: `/api/commerce/admin/wishlists/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedWishlist,
    signal,
  });
};

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

    return apiCommerceAdminWishlistsPartialUpdate(id, data);
  };

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

export type ApiCommerceAdminWishlistsPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceAdminWishlistsPartialUpdate>>
>;
export type ApiCommerceAdminWishlistsPartialUpdateMutationBody =
  NonReadonly<PatchedWishlist>;
export type ApiCommerceAdminWishlistsPartialUpdateMutationError = unknown;

/**
 * @summary Partially update wishlist (admin)
 */
export const useApiCommerceAdminWishlistsPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceAdminWishlistsPartialUpdate>>,
      TError,
      { id: number; data: NonReadonly<PatchedWishlist> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceAdminWishlistsPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedWishlist> },
  TContext
> => {
  return useMutation(
    getApiCommerceAdminWishlistsPartialUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * Admin-only wishlist management - can view and modify any user's wishlist
 * @summary Delete wishlist (admin)
 */
export const apiCommerceAdminWishlistsDestroy = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/commerce/admin/wishlists/${id}/`,
    method: "DELETE",
    signal,
  });
};

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

    return apiCommerceAdminWishlistsDestroy(id);
  };

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

export type ApiCommerceAdminWishlistsDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceAdminWishlistsDestroy>>
>;

export type ApiCommerceAdminWishlistsDestroyMutationError = unknown;

/**
 * @summary Delete wishlist (admin)
 */
export const useApiCommerceAdminWishlistsDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceAdminWishlistsDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceAdminWishlistsDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiCommerceAdminWishlistsDestroyMutationOptions(options),
    queryClient,
  );
};
/**
 * Get various analytics based on type parameter
 * @summary Get analytics data
 */
export const apiCommerceAnalyticsRetrieve = (signal?: AbortSignal) => {
  return privateMutator<void>({
    url: `/api/commerce/analytics/`,
    method: "GET",
    signal,
  });
};

export const getApiCommerceAnalyticsRetrieveQueryKey = () => {
  return [`/api/commerce/analytics/`] as const;
};

export const getApiCommerceAnalyticsRetrieveQueryOptions = <
  TData = Awaited<ReturnType<typeof apiCommerceAnalyticsRetrieve>>,
  TError = unknown,
>(options?: {
  query?: Partial<
    UseQueryOptions<
      Awaited<ReturnType<typeof apiCommerceAnalyticsRetrieve>>,
      TError,
      TData
    >
  >;
}) => {
  const { query: queryOptions } = options ?? {};

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

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

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

export type ApiCommerceAnalyticsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceAnalyticsRetrieve>>
>;
export type ApiCommerceAnalyticsRetrieveQueryError = unknown;

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

export function useApiCommerceAnalyticsRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceAnalyticsRetrieve>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceAnalyticsRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getApiCommerceAnalyticsRetrieveQueryOptions(options);

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

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

/**
 * Generate custom analytics based on specified modules and parameters
 * @summary Generate custom analytics report
 */
export const apiCommerceAnalyticsCreate = (signal?: AbortSignal) => {
  return privateMutator<void>({
    url: `/api/commerce/analytics/`,
    method: "POST",
    signal,
  });
};

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

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

export type ApiCommerceAnalyticsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceAnalyticsCreate>>
>;

export type ApiCommerceAnalyticsCreateMutationError = unknown;

/**
 * @summary Generate custom analytics report
 */
export const useApiCommerceAnalyticsCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceAnalyticsCreate>>,
      TError,
      void,
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceAnalyticsCreate>>,
  TError,
  void,
  TContext
> => {
  return useMutation(
    getApiCommerceAnalyticsCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Create category (auth required)
 */
export const apiCommerceCategoriesCreate = (
  category: NonReadonly<Category>,
  signal?: AbortSignal,
) => {
  return privateMutator<Category>({
    url: `/api/commerce/categories/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: category,
    signal,
  });
};

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

    return apiCommerceCategoriesCreate(data);
  };

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

export type ApiCommerceCategoriesCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceCategoriesCreate>>
>;
export type ApiCommerceCategoriesCreateMutationBody = NonReadonly<Category>;
export type ApiCommerceCategoriesCreateMutationError = unknown;

/**
 * @summary Create category (auth required)
 */
export const useApiCommerceCategoriesCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceCategoriesCreate>>,
      TError,
      { data: NonReadonly<Category> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceCategoriesCreate>>,
  TError,
  { data: NonReadonly<Category> },
  TContext
> => {
  return useMutation(
    getApiCommerceCategoriesCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Replace category (auth required)
 */
export const apiCommerceCategoriesUpdate = (
  id: number,
  category: NonReadonly<Category>,
  signal?: AbortSignal,
) => {
  return privateMutator<Category>({
    url: `/api/commerce/categories/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: category,
    signal,
  });
};

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

    return apiCommerceCategoriesUpdate(id, data);
  };

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

export type ApiCommerceCategoriesUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceCategoriesUpdate>>
>;
export type ApiCommerceCategoriesUpdateMutationBody = NonReadonly<Category>;
export type ApiCommerceCategoriesUpdateMutationError = unknown;

/**
 * @summary Replace category (auth required)
 */
export const useApiCommerceCategoriesUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceCategoriesUpdate>>,
      TError,
      { id: number; data: NonReadonly<Category> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceCategoriesUpdate>>,
  TError,
  { id: number; data: NonReadonly<Category> },
  TContext
> => {
  return useMutation(
    getApiCommerceCategoriesUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Update category (auth required)
 */
export const apiCommerceCategoriesPartialUpdate = (
  id: number,
  patchedCategory: NonReadonly<PatchedCategory>,
  signal?: AbortSignal,
) => {
  return privateMutator<Category>({
    url: `/api/commerce/categories/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedCategory,
    signal,
  });
};

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

    return apiCommerceCategoriesPartialUpdate(id, data);
  };

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

export type ApiCommerceCategoriesPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>
>;
export type ApiCommerceCategoriesPartialUpdateMutationBody =
  NonReadonly<PatchedCategory>;
export type ApiCommerceCategoriesPartialUpdateMutationError = unknown;

/**
 * @summary Update category (auth required)
 */
export const useApiCommerceCategoriesPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>,
      TError,
      { id: number; data: NonReadonly<PatchedCategory> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceCategoriesPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedCategory> },
  TContext
> => {
  return useMutation(
    getApiCommerceCategoriesPartialUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Delete category (auth required)
 */
export const apiCommerceCategoriesDestroy = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/commerce/categories/${id}/`,
    method: "DELETE",
    signal,
  });
};

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

    return apiCommerceCategoriesDestroy(id);
  };

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

export type ApiCommerceCategoriesDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceCategoriesDestroy>>
>;

export type ApiCommerceCategoriesDestroyMutationError = unknown;

/**
 * @summary Delete category (auth required)
 */
export const useApiCommerceCategoriesDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceCategoriesDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceCategoriesDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiCommerceCategoriesDestroyMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Create discount code (auth required)
 */
export const apiCommerceDiscountCodesCreate = (
  discountCode: NonReadonly<DiscountCode>,
  signal?: AbortSignal,
) => {
  return privateMutator<DiscountCode>({
    url: `/api/commerce/discount-codes/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: discountCode,
    signal,
  });
};

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

    return apiCommerceDiscountCodesCreate(data);
  };

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

export type ApiCommerceDiscountCodesCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesCreate>>
>;
export type ApiCommerceDiscountCodesCreateMutationBody =
  NonReadonly<DiscountCode>;
export type ApiCommerceDiscountCodesCreateMutationError = unknown;

/**
 * @summary Create discount code (auth required)
 */
export const useApiCommerceDiscountCodesCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceDiscountCodesCreate>>,
      TError,
      { data: NonReadonly<DiscountCode> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesCreate>>,
  TError,
  { data: NonReadonly<DiscountCode> },
  TContext
> => {
  return useMutation(
    getApiCommerceDiscountCodesCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Replace discount code (auth required)
 */
export const apiCommerceDiscountCodesUpdate = (
  id: number,
  discountCode: NonReadonly<DiscountCode>,
  signal?: AbortSignal,
) => {
  return privateMutator<DiscountCode>({
    url: `/api/commerce/discount-codes/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: discountCode,
    signal,
  });
};

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

    return apiCommerceDiscountCodesUpdate(id, data);
  };

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

export type ApiCommerceDiscountCodesUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesUpdate>>
>;
export type ApiCommerceDiscountCodesUpdateMutationBody =
  NonReadonly<DiscountCode>;
export type ApiCommerceDiscountCodesUpdateMutationError = unknown;

/**
 * @summary Replace discount code (auth required)
 */
export const useApiCommerceDiscountCodesUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceDiscountCodesUpdate>>,
      TError,
      { id: number; data: NonReadonly<DiscountCode> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesUpdate>>,
  TError,
  { id: number; data: NonReadonly<DiscountCode> },
  TContext
> => {
  return useMutation(
    getApiCommerceDiscountCodesUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Update discount code (auth required)
 */
export const apiCommerceDiscountCodesPartialUpdate = (
  id: number,
  patchedDiscountCode: NonReadonly<PatchedDiscountCode>,
  signal?: AbortSignal,
) => {
  return privateMutator<DiscountCode>({
    url: `/api/commerce/discount-codes/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedDiscountCode,
    signal,
  });
};

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

    return apiCommerceDiscountCodesPartialUpdate(id, data);
  };

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

export type ApiCommerceDiscountCodesPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>
>;
export type ApiCommerceDiscountCodesPartialUpdateMutationBody =
  NonReadonly<PatchedDiscountCode>;
export type ApiCommerceDiscountCodesPartialUpdateMutationError = unknown;

/**
 * @summary Update discount code (auth required)
 */
export const useApiCommerceDiscountCodesPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>,
      TError,
      { id: number; data: NonReadonly<PatchedDiscountCode> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedDiscountCode> },
  TContext
> => {
  return useMutation(
    getApiCommerceDiscountCodesPartialUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Delete discount code (auth required)
 */
export const apiCommerceDiscountCodesDestroy = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/commerce/discount-codes/${id}/`,
    method: "DELETE",
    signal,
  });
};

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

    return apiCommerceDiscountCodesDestroy(id);
  };

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

export type ApiCommerceDiscountCodesDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesDestroy>>
>;

export type ApiCommerceDiscountCodesDestroyMutationError = unknown;

/**
 * @summary Delete discount code (auth required)
 */
export const useApiCommerceDiscountCodesDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceDiscountCodesDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiCommerceDiscountCodesDestroyMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Create product image (auth required)
 */
export const apiCommerceProductImagesCreate = (
  productImage: NonReadonly<ProductImage>,
  signal?: AbortSignal,
) => {
  return privateMutator<ProductImage>({
    url: `/api/commerce/product-images/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: productImage,
    signal,
  });
};

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

    return apiCommerceProductImagesCreate(data);
  };

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

export type ApiCommerceProductImagesCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductImagesCreate>>
>;
export type ApiCommerceProductImagesCreateMutationBody =
  NonReadonly<ProductImage>;
export type ApiCommerceProductImagesCreateMutationError = unknown;

/**
 * @summary Create product image (auth required)
 */
export const useApiCommerceProductImagesCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceProductImagesCreate>>,
      TError,
      { data: NonReadonly<ProductImage> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceProductImagesCreate>>,
  TError,
  { data: NonReadonly<ProductImage> },
  TContext
> => {
  return useMutation(
    getApiCommerceProductImagesCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Replace product image (auth required)
 */
export const apiCommerceProductImagesUpdate = (
  id: number,
  productImage: NonReadonly<ProductImage>,
  signal?: AbortSignal,
) => {
  return privateMutator<ProductImage>({
    url: `/api/commerce/product-images/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: productImage,
    signal,
  });
};

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

    return apiCommerceProductImagesUpdate(id, data);
  };

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

export type ApiCommerceProductImagesUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductImagesUpdate>>
>;
export type ApiCommerceProductImagesUpdateMutationBody =
  NonReadonly<ProductImage>;
export type ApiCommerceProductImagesUpdateMutationError = unknown;

/**
 * @summary Replace product image (auth required)
 */
export const useApiCommerceProductImagesUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceProductImagesUpdate>>,
      TError,
      { id: number; data: NonReadonly<ProductImage> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceProductImagesUpdate>>,
  TError,
  { id: number; data: NonReadonly<ProductImage> },
  TContext
> => {
  return useMutation(
    getApiCommerceProductImagesUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Update product image (auth required)
 */
export const apiCommerceProductImagesPartialUpdate = (
  id: number,
  patchedProductImage: NonReadonly<PatchedProductImage>,
  signal?: AbortSignal,
) => {
  return privateMutator<ProductImage>({
    url: `/api/commerce/product-images/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedProductImage,
    signal,
  });
};

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

    return apiCommerceProductImagesPartialUpdate(id, data);
  };

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

export type ApiCommerceProductImagesPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>
>;
export type ApiCommerceProductImagesPartialUpdateMutationBody =
  NonReadonly<PatchedProductImage>;
export type ApiCommerceProductImagesPartialUpdateMutationError = unknown;

/**
 * @summary Update product image (auth required)
 */
export const useApiCommerceProductImagesPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>,
      TError,
      { id: number; data: NonReadonly<PatchedProductImage> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceProductImagesPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedProductImage> },
  TContext
> => {
  return useMutation(
    getApiCommerceProductImagesPartialUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Delete product image (auth required)
 */
export const apiCommerceProductImagesDestroy = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/commerce/product-images/${id}/`,
    method: "DELETE",
    signal,
  });
};

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

    return apiCommerceProductImagesDestroy(id);
  };

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

export type ApiCommerceProductImagesDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductImagesDestroy>>
>;

export type ApiCommerceProductImagesDestroyMutationError = unknown;

/**
 * @summary Delete product image (auth required)
 */
export const useApiCommerceProductImagesDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceProductImagesDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceProductImagesDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiCommerceProductImagesDestroyMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Create product (auth required)
 */
export const apiCommerceProductsCreate = (
  product: NonReadonly<Product>,
  signal?: AbortSignal,
) => {
  return privateMutator<Product>({
    url: `/api/commerce/products/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: product,
    signal,
  });
};

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

    return apiCommerceProductsCreate(data);
  };

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

export type ApiCommerceProductsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductsCreate>>
>;
export type ApiCommerceProductsCreateMutationBody = NonReadonly<Product>;
export type ApiCommerceProductsCreateMutationError = unknown;

/**
 * @summary Create product (auth required)
 */
export const useApiCommerceProductsCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceProductsCreate>>,
      TError,
      { data: NonReadonly<Product> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceProductsCreate>>,
  TError,
  { data: NonReadonly<Product> },
  TContext
> => {
  return useMutation(
    getApiCommerceProductsCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Replace product (auth required)
 */
export const apiCommerceProductsUpdate = (
  id: number,
  product: NonReadonly<Product>,
  signal?: AbortSignal,
) => {
  return privateMutator<Product>({
    url: `/api/commerce/products/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: product,
    signal,
  });
};

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

    return apiCommerceProductsUpdate(id, data);
  };

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

export type ApiCommerceProductsUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductsUpdate>>
>;
export type ApiCommerceProductsUpdateMutationBody = NonReadonly<Product>;
export type ApiCommerceProductsUpdateMutationError = unknown;

/**
 * @summary Replace product (auth required)
 */
export const useApiCommerceProductsUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceProductsUpdate>>,
      TError,
      { id: number; data: NonReadonly<Product> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceProductsUpdate>>,
  TError,
  { id: number; data: NonReadonly<Product> },
  TContext
> => {
  return useMutation(
    getApiCommerceProductsUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Update product (auth required)
 */
export const apiCommerceProductsPartialUpdate = (
  id: number,
  patchedProduct: NonReadonly<PatchedProduct>,
  signal?: AbortSignal,
) => {
  return privateMutator<Product>({
    url: `/api/commerce/products/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedProduct,
    signal,
  });
};

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

    return apiCommerceProductsPartialUpdate(id, data);
  };

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

export type ApiCommerceProductsPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductsPartialUpdate>>
>;
export type ApiCommerceProductsPartialUpdateMutationBody =
  NonReadonly<PatchedProduct>;
export type ApiCommerceProductsPartialUpdateMutationError = unknown;

/**
 * @summary Update product (auth required)
 */
export const useApiCommerceProductsPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceProductsPartialUpdate>>,
      TError,
      { id: number; data: NonReadonly<PatchedProduct> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceProductsPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedProduct> },
  TContext
> => {
  return useMutation(
    getApiCommerceProductsPartialUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Delete product (auth required)
 */
export const apiCommerceProductsDestroy = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/commerce/products/${id}/`,
    method: "DELETE",
    signal,
  });
};

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

    return apiCommerceProductsDestroy(id);
  };

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

export type ApiCommerceProductsDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductsDestroy>>
>;

export type ApiCommerceProductsDestroyMutationError = unknown;

/**
 * @summary Delete product (auth required)
 */
export const useApiCommerceProductsDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceProductsDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceProductsDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiCommerceProductsDestroyMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary List refunds (admin)
 */
export const apiCommerceRefundsList = (
  params?: ApiCommerceRefundsListParams,
  signal?: AbortSignal,
) => {
  return privateMutator<PaginatedRefundList>({
    url: `/api/commerce/refunds/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiCommerceRefundsListQueryKey = (
  params?: ApiCommerceRefundsListParams,
) => {
  return [`/api/commerce/refunds/`, ...(params ? [params] : [])] as const;
};

export const getApiCommerceRefundsListQueryOptions = <
  TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
  TError = unknown,
>(
  params?: ApiCommerceRefundsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceRefundsList>>,
        TError,
        TData
      >
    >;
  },
) => {
  const { query: queryOptions } = options ?? {};

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

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

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

export type ApiCommerceRefundsListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceRefundsList>>
>;
export type ApiCommerceRefundsListQueryError = unknown;

export function useApiCommerceRefundsList<
  TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
  TError = unknown,
>(
  params: undefined | ApiCommerceRefundsListParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceRefundsList>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceRefundsList>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceRefundsList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceRefundsList<
  TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
  TError = unknown,
>(
  params?: ApiCommerceRefundsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceRefundsList>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceRefundsList>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceRefundsList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceRefundsList<
  TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
  TError = unknown,
>(
  params?: ApiCommerceRefundsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceRefundsList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List refunds (admin)
 */

export function useApiCommerceRefundsList<
  TData = Awaited<ReturnType<typeof apiCommerceRefundsList>>,
  TError = unknown,
>(
  params?: ApiCommerceRefundsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceRefundsList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getApiCommerceRefundsListQueryOptions(params, options);

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

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

/**
 * @summary Create refund (admin)
 */
export const apiCommerceRefundsCreate = (
  refund: NonReadonly<Refund>,
  signal?: AbortSignal,
) => {
  return privateMutator<Refund>({
    url: `/api/commerce/refunds/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: refund,
    signal,
  });
};

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

    return apiCommerceRefundsCreate(data);
  };

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

export type ApiCommerceRefundsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceRefundsCreate>>
>;
export type ApiCommerceRefundsCreateMutationBody = NonReadonly<Refund>;
export type ApiCommerceRefundsCreateMutationError = unknown;

/**
 * @summary Create refund (admin)
 */
export const useApiCommerceRefundsCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceRefundsCreate>>,
      TError,
      { data: NonReadonly<Refund> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceRefundsCreate>>,
  TError,
  { data: NonReadonly<Refund> },
  TContext
> => {
  return useMutation(
    getApiCommerceRefundsCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Retrieve refund (admin)
 */
export const apiCommerceRefundsRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<Refund>({
    url: `/api/commerce/refunds/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiCommerceRefundsRetrieveQueryKey = (id: number) => {
  return [`/api/commerce/refunds/${id}/`] as const;
};

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

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

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

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

export type ApiCommerceRefundsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>
>;
export type ApiCommerceRefundsRetrieveQueryError = unknown;

export function useApiCommerceRefundsRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
  TError = unknown,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceRefundsRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceRefundsRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceRefundsRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Retrieve refund (admin)
 */

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

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

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

/**
 * @summary Replace refund (admin)
 */
export const apiCommerceRefundsUpdate = (
  id: number,
  refund: NonReadonly<Refund>,
  signal?: AbortSignal,
) => {
  return privateMutator<Refund>({
    url: `/api/commerce/refunds/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: refund,
    signal,
  });
};

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

    return apiCommerceRefundsUpdate(id, data);
  };

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

export type ApiCommerceRefundsUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceRefundsUpdate>>
>;
export type ApiCommerceRefundsUpdateMutationBody = NonReadonly<Refund>;
export type ApiCommerceRefundsUpdateMutationError = unknown;

/**
 * @summary Replace refund (admin)
 */
export const useApiCommerceRefundsUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceRefundsUpdate>>,
      TError,
      { id: number; data: NonReadonly<Refund> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceRefundsUpdate>>,
  TError,
  { id: number; data: NonReadonly<Refund> },
  TContext
> => {
  return useMutation(
    getApiCommerceRefundsUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Update refund (admin)
 */
export const apiCommerceRefundsPartialUpdate = (
  id: number,
  patchedRefund: NonReadonly<PatchedRefund>,
  signal?: AbortSignal,
) => {
  return privateMutator<Refund>({
    url: `/api/commerce/refunds/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedRefund,
    signal,
  });
};

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

    return apiCommerceRefundsPartialUpdate(id, data);
  };

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

export type ApiCommerceRefundsPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceRefundsPartialUpdate>>
>;
export type ApiCommerceRefundsPartialUpdateMutationBody =
  NonReadonly<PatchedRefund>;
export type ApiCommerceRefundsPartialUpdateMutationError = unknown;

/**
 * @summary Update refund (admin)
 */
export const useApiCommerceRefundsPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceRefundsPartialUpdate>>,
      TError,
      { id: number; data: NonReadonly<PatchedRefund> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceRefundsPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedRefund> },
  TContext
> => {
  return useMutation(
    getApiCommerceRefundsPartialUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Delete refund (admin)
 */
export const apiCommerceRefundsDestroy = (id: number, signal?: AbortSignal) => {
  return privateMutator<void>({
    url: `/api/commerce/refunds/${id}/`,
    method: "DELETE",
    signal,
  });
};

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

    return apiCommerceRefundsDestroy(id);
  };

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

export type ApiCommerceRefundsDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceRefundsDestroy>>
>;

export type ApiCommerceRefundsDestroyMutationError = unknown;

/**
 * @summary Delete refund (admin)
 */
export const useApiCommerceRefundsDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceRefundsDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceRefundsDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiCommerceRefundsDestroyMutationOptions(options),
    queryClient,
  );
};
