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

import type {
  HTTPValidationError,
  MarketingReportResponse
} from '../../model';

import { customFetcher } from '../../api';


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



/**
 * @summary Get Report
 */
export type getReportResponse200 = {
  data: MarketingReportResponse
  status: 200
}

export type getReportResponse422 = {
  data: HTTPValidationError
  status: 422
}
    
export type getReportResponseSuccess = (getReportResponse200) & {
  headers: Headers;
};
export type getReportResponseError = (getReportResponse422) & {
  headers: Headers;
};

export type getReportResponse = (getReportResponseSuccess | getReportResponseError)

export const getGetReportUrl = (runId: string,) => {


  

  return `/api/report/${runId}`
}

export const getReport = async (runId: string, options?: RequestInit): Promise<getReportResponse> => {
  
  return customFetcher<getReportResponse>(getGetReportUrl(runId),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetReportQueryKey = (runId?: string,) => {
    return [
    `/api/report/${runId}`
    ] as const;
    }

    
export const getGetReportQueryOptions = <TData = Awaited<ReturnType<typeof getReport>>, TError = HTTPValidationError>(runId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getReport>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
) => {

const {query: queryOptions, request: requestOptions} = options ?? {};

  const queryKey =  queryOptions?.queryKey ?? getGetReportQueryKey(runId);

  

    const queryFn: QueryFunction<Awaited<ReturnType<typeof getReport>>> = () => getReport(runId, requestOptions);

      

      

   return  { queryKey, queryFn, enabled: !!(runId),  staleTime: 60000,  ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getReport>>, TError, TData> & { queryKey: DataTag<QueryKey, TData> }
}

export type GetReportQueryResult = NonNullable<Awaited<ReturnType<typeof getReport>>>
export type GetReportQueryError = HTTPValidationError


export function useGetReport<TData = Awaited<ReturnType<typeof getReport>>, TError = HTTPValidationError>(
 runId: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getReport>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getReport>>,
          TError,
          Awaited<ReturnType<typeof getReport>>
        > , 'initialData'
      >, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
export function useGetReport<TData = Awaited<ReturnType<typeof getReport>>, TError = HTTPValidationError>(
 runId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getReport>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getReport>>,
          TError,
          Awaited<ReturnType<typeof getReport>>
        > , 'initialData'
      >, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
export function useGetReport<TData = Awaited<ReturnType<typeof getReport>>, TError = HTTPValidationError>(
 runId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getReport>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> }
/**
 * @summary Get Report
 */

export function useGetReport<TData = Awaited<ReturnType<typeof getReport>>, TError = HTTPValidationError>(
 runId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getReport>>, TError, TData>>, request?: SecondParameter<typeof customFetcher>}
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData> } {

  const queryOptions = getGetReportQueryOptions(runId,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}




