/**
 * 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 {
  ApiCommerceCategoriesListParams,
  ApiCommerceDiscountCodesListParams,
  ApiCommerceOrdersListParams,
  ApiCommerceProductImagesListParams,
  ApiCommerceProductsListParams,
  Category,
  DiscountCode,
  OrderCreate,
  OrderRead,
  PaginatedCategoryList,
  PaginatedDiscountCodeList,
  PaginatedOrderReadList,
  PaginatedProductImageList,
  PaginatedProductList,
  Product,
  ProductImage,
  ReviewSerializerPublic,
} from "./models";

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

// 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>;

/**
 * @summary List categories (public)
 */
export const apiCommerceCategoriesList = (
  params?: ApiCommerceCategoriesListParams,
  signal?: AbortSignal,
) => {
  return publicMutator<PaginatedCategoryList>({
    url: `/api/commerce/categories/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiCommerceCategoriesListQueryKey = (
  params?: ApiCommerceCategoriesListParams,
) => {
  return [`/api/commerce/categories/`, ...(params ? [params] : [])] as const;
};

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

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

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

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

export type ApiCommerceCategoriesListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceCategoriesList>>
>;
export type ApiCommerceCategoriesListQueryError = unknown;

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

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

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

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

/**
 * @summary Retrieve category (public)
 */
export const apiCommerceCategoriesRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return publicMutator<Category>({
    url: `/api/commerce/categories/${id}/`,
    method: "GET",
    signal,
  });
};

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

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

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

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

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

export type ApiCommerceCategoriesRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceCategoriesRetrieve>>
>;
export type ApiCommerceCategoriesRetrieveQueryError = unknown;

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

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

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

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

/**
 * @summary List discount codes (public)
 */
export const apiCommerceDiscountCodesList = (
  params?: ApiCommerceDiscountCodesListParams,
  signal?: AbortSignal,
) => {
  return publicMutator<PaginatedDiscountCodeList>({
    url: `/api/commerce/discount-codes/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiCommerceDiscountCodesListQueryKey = (
  params?: ApiCommerceDiscountCodesListParams,
) => {
  return [
    `/api/commerce/discount-codes/`,
    ...(params ? [params] : []),
  ] as const;
};

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

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

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

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

export type ApiCommerceDiscountCodesListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesList>>
>;
export type ApiCommerceDiscountCodesListQueryError = unknown;

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

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

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

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

/**
 * @summary Retrieve discount code (public)
 */
export const apiCommerceDiscountCodesRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return publicMutator<DiscountCode>({
    url: `/api/commerce/discount-codes/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiCommerceDiscountCodesRetrieveQueryKey = (id: number) => {
  return [`/api/commerce/discount-codes/${id}/`] as const;
};

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

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

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

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

export type ApiCommerceDiscountCodesRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceDiscountCodesRetrieve>>
>;
export type ApiCommerceDiscountCodesRetrieveQueryError = unknown;

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

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

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

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

/**
 * @summary List Orders (public - anonymous orders, authenticated - user orders, admin - all orders)
 */
export const apiCommerceOrdersList = (
  params?: ApiCommerceOrdersListParams,
  signal?: AbortSignal,
) => {
  return publicMutator<PaginatedOrderReadList>({
    url: `/api/commerce/orders/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiCommerceOrdersListQueryKey = (
  params?: ApiCommerceOrdersListParams,
) => {
  return [`/api/commerce/orders/`, ...(params ? [params] : [])] as const;
};

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

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

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

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

export type ApiCommerceOrdersListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceOrdersList>>
>;
export type ApiCommerceOrdersListQueryError = unknown;

export function useApiCommerceOrdersList<
  TData = Awaited<ReturnType<typeof apiCommerceOrdersList>>,
  TError = unknown,
>(
  params: undefined | ApiCommerceOrdersListParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceOrdersList>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceOrdersList>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceOrdersList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceOrdersList<
  TData = Awaited<ReturnType<typeof apiCommerceOrdersList>>,
  TError = unknown,
>(
  params?: ApiCommerceOrdersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceOrdersList>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceOrdersList>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceOrdersList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceOrdersList<
  TData = Awaited<ReturnType<typeof apiCommerceOrdersList>>,
  TError = unknown,
>(
  params?: ApiCommerceOrdersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceOrdersList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Orders (public - anonymous orders, authenticated - user orders, admin - all orders)
 */

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

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

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

/**
 * @summary Create Order (public)
 */
export const apiCommerceOrdersCreate = (
  orderCreate: OrderCreate,
  signal?: AbortSignal,
) => {
  return publicMutator<OrderCreate>({
    url: `/api/commerce/orders/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: orderCreate,
    signal,
  });
};

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

    return apiCommerceOrdersCreate(data);
  };

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

export type ApiCommerceOrdersCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceOrdersCreate>>
>;
export type ApiCommerceOrdersCreateMutationBody = OrderCreate;
export type ApiCommerceOrdersCreateMutationError = unknown;

/**
 * @summary Create Order (public)
 */
export const useApiCommerceOrdersCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceOrdersCreate>>,
      TError,
      { data: OrderCreate },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceOrdersCreate>>,
  TError,
  { data: OrderCreate },
  TContext
> => {
  return useMutation(
    getApiCommerceOrdersCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * @summary Retrieve Order (public - anonymous orders, authenticated - user orders, admin - all orders)
 */
export const apiCommerceOrdersRetrieve = (id: number, signal?: AbortSignal) => {
  return publicMutator<OrderRead>({
    url: `/api/commerce/orders/${id}/`,
    method: "GET",
    signal,
  });
};

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

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

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

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

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

export type ApiCommerceOrdersRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>
>;
export type ApiCommerceOrdersRetrieveQueryError = unknown;

export function useApiCommerceOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiCommerceOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiCommerceOrdersRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Retrieve Order (public - anonymous orders, authenticated - user orders, admin - all orders)
 */

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

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

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

/**
 * @summary List product images (public)
 */
export const apiCommerceProductImagesList = (
  params?: ApiCommerceProductImagesListParams,
  signal?: AbortSignal,
) => {
  return publicMutator<PaginatedProductImageList>({
    url: `/api/commerce/product-images/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiCommerceProductImagesListQueryKey = (
  params?: ApiCommerceProductImagesListParams,
) => {
  return [
    `/api/commerce/product-images/`,
    ...(params ? [params] : []),
  ] as const;
};

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

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

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

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

export type ApiCommerceProductImagesListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductImagesList>>
>;
export type ApiCommerceProductImagesListQueryError = unknown;

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

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

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

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

/**
 * @summary Retrieve product image (public)
 */
export const apiCommerceProductImagesRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return publicMutator<ProductImage>({
    url: `/api/commerce/product-images/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiCommerceProductImagesRetrieveQueryKey = (id: number) => {
  return [`/api/commerce/product-images/${id}/`] as const;
};

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

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

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

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

export type ApiCommerceProductImagesRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductImagesRetrieve>>
>;
export type ApiCommerceProductImagesRetrieveQueryError = unknown;

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

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

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

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

/**
 * @summary List products (public)
 */
export const apiCommerceProductsList = (
  params?: ApiCommerceProductsListParams,
  signal?: AbortSignal,
) => {
  return publicMutator<PaginatedProductList>({
    url: `/api/commerce/products/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiCommerceProductsListQueryKey = (
  params?: ApiCommerceProductsListParams,
) => {
  return [`/api/commerce/products/`, ...(params ? [params] : [])] as const;
};

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

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

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

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

export type ApiCommerceProductsListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductsList>>
>;
export type ApiCommerceProductsListQueryError = unknown;

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

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

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

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

/**
 * @summary Retrieve product (public)
 */
export const apiCommerceProductsRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return publicMutator<Product>({
    url: `/api/commerce/products/${id}/`,
    method: "GET",
    signal,
  });
};

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

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

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

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

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

export type ApiCommerceProductsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceProductsRetrieve>>
>;
export type ApiCommerceProductsRetrieveQueryError = unknown;

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

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

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

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

/**
 * Public endpoint to create a review for a product.
 * @summary Create a product review (public)
 */
export const apiCommerceReviewsCreateCreate = (
  reviewSerializerPublic: NonReadonly<ReviewSerializerPublic>,
  signal?: AbortSignal,
) => {
  return publicMutator<ReviewSerializerPublic>({
    url: `/api/commerce/reviews/create/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: reviewSerializerPublic,
    signal,
  });
};

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

    return apiCommerceReviewsCreateCreate(data);
  };

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

export type ApiCommerceReviewsCreateCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiCommerceReviewsCreateCreate>>
>;
export type ApiCommerceReviewsCreateCreateMutationBody =
  NonReadonly<ReviewSerializerPublic>;
export type ApiCommerceReviewsCreateCreateMutationError = unknown;

/**
 * @summary Create a product review (public)
 */
export const useApiCommerceReviewsCreateCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiCommerceReviewsCreateCreate>>,
      TError,
      { data: NonReadonly<ReviewSerializerPublic> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiCommerceReviewsCreateCreate>>,
  TError,
  { data: NonReadonly<ReviewSerializerPublic> },
  TContext
> => {
  return useMutation(
    getApiCommerceReviewsCreateCreateMutationOptions(options),
    queryClient,
  );
};
