/**
 * Generated by orval 🍺
 * Do not edit manually.
 * messages API
 * This is the messages API schema.
 * OpenAPI spec version: 1.0.0 (v1.0)
 */
import { useQuery } from "@tanstack/react-query";
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseQueryResult,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseQueryOptions,
  UseQueryResult,
} from "@tanstack/react-query";

import type { PlaceholdersRetrieve200 } from ".././models";

import { fetchAPI } from "../../fetch-api";

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

/**
 * Get the structure of all available fields with their labels
 * @summary Get field structure
 */
export type placeholdersRetrieveResponse200 = {
  data: PlaceholdersRetrieve200;
  status: 200;
};

export type placeholdersRetrieveResponseSuccess =
  placeholdersRetrieveResponse200 & {
    headers: Headers;
  };
export type placeholdersRetrieveResponse = placeholdersRetrieveResponseSuccess;

export const getPlaceholdersRetrieveUrl = () => {
  return `/api/v1.0/placeholders/`;
};

export const placeholdersRetrieve = async (
  options?: RequestInit,
): Promise<placeholdersRetrieveResponse> => {
  return fetchAPI<placeholdersRetrieveResponse>(getPlaceholdersRetrieveUrl(), {
    ...options,
    method: "GET",
  });
};

export const getPlaceholdersRetrieveQueryKey = () => {
  return [`/api/v1.0/placeholders/`] as const;
};

export const getPlaceholdersRetrieveQueryOptions = <
  TData = Awaited<ReturnType<typeof placeholdersRetrieve>>,
  TError = unknown,
>(options?: {
  query?: Partial<
    UseQueryOptions<
      Awaited<ReturnType<typeof placeholdersRetrieve>>,
      TError,
      TData
    >
  >;
  request?: SecondParameter<typeof fetchAPI>;
}) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

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

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

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

export type PlaceholdersRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof placeholdersRetrieve>>
>;
export type PlaceholdersRetrieveQueryError = unknown;

export function usePlaceholdersRetrieve<
  TData = Awaited<ReturnType<typeof placeholdersRetrieve>>,
  TError = unknown,
>(
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof placeholdersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof placeholdersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof placeholdersRetrieve>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function usePlaceholdersRetrieve<
  TData = Awaited<ReturnType<typeof placeholdersRetrieve>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof placeholdersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof placeholdersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof placeholdersRetrieve>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function usePlaceholdersRetrieve<
  TData = Awaited<ReturnType<typeof placeholdersRetrieve>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof placeholdersRetrieve>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get field structure
 */

export function usePlaceholdersRetrieve<
  TData = Awaited<ReturnType<typeof placeholdersRetrieve>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof placeholdersRetrieve>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getPlaceholdersRetrieveQueryOptions(options);

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

  query.queryKey = queryOptions.queryKey;

  return query;
}
