/**
 * Generated by orval v7.17.0 🍺
 * Do not edit manually.
 * OpenAPI spec version: 0.0.0
 */
import { useQuery } from "@tanstack/react-query";
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseQueryResult,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseQueryOptions,
  UseQueryResult,
} from "@tanstack/react-query";

import type {
  ApiConfigurationPublicShopConfigurationListParams,
  PaginatedSiteConfigurationPublicList,
  SiteConfigurationPublic,
} from "./models";

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

/**
 * @summary List site configuration (public)
 */
export const apiConfigurationPublicShopConfigurationList = (
  params?: ApiConfigurationPublicShopConfigurationListParams,
  signal?: AbortSignal,
) => {
  return publicMutator<PaginatedSiteConfigurationPublicList>({
    url: `/api/configuration/public/shop-configuration/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiConfigurationPublicShopConfigurationListQueryKey = (
  params?: ApiConfigurationPublicShopConfigurationListParams,
) => {
  return [
    `/api/configuration/public/shop-configuration/`,
    ...(params ? [params] : []),
  ] as const;
};

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

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

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

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

export type ApiConfigurationPublicShopConfigurationListQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationList>>
  >;
export type ApiConfigurationPublicShopConfigurationListQueryError = unknown;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * @summary Retrieve site configuration (public)
 */
export const apiConfigurationPublicShopConfigurationRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return publicMutator<SiteConfigurationPublic>({
    url: `/api/configuration/public/shop-configuration/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiConfigurationPublicShopConfigurationRetrieveQueryKey = (
  id?: number,
) => {
  return [`/api/configuration/public/shop-configuration/${id}/`] as const;
};

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

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

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

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

export type ApiConfigurationPublicShopConfigurationRetrieveQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof apiConfigurationPublicShopConfigurationRetrieve>>
  >;
export type ApiConfigurationPublicShopConfigurationRetrieveQueryError = unknown;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}
