/**
 * Generated by orval v6.31.0 🍺
 * Do not edit manually.
 * pkh-api
 * pkh api
 * OpenAPI spec version: 0.0.1
 */
import { useQuery } from '@tanstack/react-query';
import type { QueryFunction, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
import { drcInstance } from '../../../configs/mutator/drc-instance';
import type { ErrorType } from '../../../configs/mutator/drc-instance';
import type { PingResponse } from '../../models';

export const pingControllerPing = (signal?: AbortSignal) => {
  return drcInstance<PingResponse>({ url: `/ping`, method: 'GET', signal });
};

export const getPingControllerPingQueryKey = () => {
  return [`/ping`] as const;
};

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

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

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

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

export type PingControllerPingQueryResult = NonNullable<Awaited<ReturnType<typeof pingControllerPing>>>;
export type PingControllerPingQueryError = ErrorType<unknown>;

export const usePingControllerPing = <
  TData = Awaited<ReturnType<typeof pingControllerPing>>,
  TError = ErrorType<unknown>,
>(options?: {
  query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof pingControllerPing>>, TError, TData>>;
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
  const queryOptions = getPingControllerPingQueryOptions(options);

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

  query.queryKey = queryOptions.queryKey;

  return query;
};
