/**
 * Generated by orval. Do not edit manually.
 * O-replay - OpenAPI 3.0
 * O-replay Rest API
 */
import {
  useMutation,
  useQuery
} from 'react-query';
import type {
  MutationFunction,
  QueryClient,
  QueryFunction,
  QueryKey,
  UseMutationOptions,
  UseMutationResult,
  UseQueryOptions,
  UseQueryResult
} from 'react-query';

import type {
  GetListEventsParams,
  PaginatedEvent,
  PatchEventsBody,
  PostListEventsBody,
  ResEvent
} from '../../../domain/types/v1api';

import { orvalAxiosInstance } from '../../orval/orval-axios-instance';


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



/**
 * Get list
 */
export const getListEvents = (
    params?: GetListEventsParams,
 options?: SecondParameter<typeof orvalAxiosInstance>,signal?: AbortSignal
) => {
      
      
      return orvalAxiosInstance<PaginatedEvent>(
      {url: `/api/v1/events/`, method: 'GET',
        params, signal
    },
      options);
    }
  



export const getGetListEventsQueryKey = (params?: GetListEventsParams,) => {
    return [
    `/api/v1/events/`, ...(params ? [params]: [])
    ] as const;
    }

    
export const getGetListEventsQueryOptions = <TData = Awaited<ReturnType<typeof getListEvents>>, TError = unknown>(params?: GetListEventsParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getListEvents>>, TError, TData>, request?: SecondParameter<typeof orvalAxiosInstance>}
) => {

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

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

  

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

      

      

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

export type GetListEventsQueryResult = NonNullable<Awaited<ReturnType<typeof getListEvents>>>
export type GetListEventsQueryError = unknown



export function useGetListEvents<TData = Awaited<ReturnType<typeof getListEvents>>, TError = unknown>(
 params?: GetListEventsParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getListEvents>>, TError, TData>, request?: SecondParameter<typeof orvalAxiosInstance>}
  
 ):  UseQueryResult<TData, TError> & { queryKey: QueryKey } {

  const queryOptions = getGetListEventsQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

export const prefetchGetListEventsQuery = async <TData = Awaited<ReturnType<typeof getListEvents>>, TError = unknown>(
 queryClient: QueryClient, params?: GetListEventsParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getListEvents>>, TError, TData>, request?: SecondParameter<typeof orvalAxiosInstance>}

  ): Promise<QueryClient> => {

  const queryOptions = getGetListEventsQueryOptions(params,options)

  await queryClient.prefetchQuery(queryOptions);

  return queryClient;
}



/**
 * Add new
 */
export const postListEvents = (
    postListEventsBody: PostListEventsBody,
 options?: SecondParameter<typeof orvalAxiosInstance>,signal?: AbortSignal
) => {
      
      
      return orvalAxiosInstance<ResEvent>(
      {url: `/api/v1/events/`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: postListEventsBody, signal
    },
      options);
    }
  


export const getPostListEventsMutationOptions = <TError = unknown,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postListEvents>>, TError,{data: PostListEventsBody}, TContext>, request?: SecondParameter<typeof orvalAxiosInstance>}
): UseMutationOptions<Awaited<ReturnType<typeof postListEvents>>, TError,{data: PostListEventsBody}, TContext> => {

const mutationKey = ['postListEvents'];
const {mutation: mutationOptions, request: requestOptions} = options ?
      options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
      options
      : {...options, mutation: {...options.mutation, mutationKey}}
      : {mutation: { mutationKey, }, request: undefined};

      


      const mutationFn: MutationFunction<Awaited<ReturnType<typeof postListEvents>>, {data: PostListEventsBody}> = (props) => {
          const {data} = props ?? {};

          return  postListEvents(data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PostListEventsMutationResult = NonNullable<Awaited<ReturnType<typeof postListEvents>>>
    export type PostListEventsMutationBody = PostListEventsBody
    export type PostListEventsMutationError = unknown

    export const usePostListEvents = <TError = unknown,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postListEvents>>, TError,{data: PostListEventsBody}, TContext>, request?: SecondParameter<typeof orvalAxiosInstance>}
 ): UseMutationResult<
        Awaited<ReturnType<typeof postListEvents>>,
        TError,
        {data: PostListEventsBody},
        TContext
      > => {

      const mutationOptions = getPostListEventsMutationOptions(options);

      return useMutation(mutationOptions);
    }
    /**
 * Get data
 */
export const getEvents = (
    eventID: string,
 options?: SecondParameter<typeof orvalAxiosInstance>,signal?: AbortSignal
) => {
      
      
      return orvalAxiosInstance<ResEvent>(
      {url: `/api/v1/events/${eventID}`, method: 'GET', signal
    },
      options);
    }
  



export const getGetEventsQueryKey = (eventID?: string,) => {
    return [
    `/api/v1/events/${eventID}`
    ] as const;
    }

    
export const getGetEventsQueryOptions = <TData = Awaited<ReturnType<typeof getEvents>>, TError = unknown>(eventID: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getEvents>>, TError, TData>, request?: SecondParameter<typeof orvalAxiosInstance>}
) => {

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

  const queryKey =  queryOptions?.queryKey ?? getGetEventsQueryKey(eventID);

  

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

      

      

   return  { queryKey, queryFn, enabled: !!(eventID), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getEvents>>, TError, TData> & { queryKey: QueryKey }
}

export type GetEventsQueryResult = NonNullable<Awaited<ReturnType<typeof getEvents>>>
export type GetEventsQueryError = unknown



export function useGetEvents<TData = Awaited<ReturnType<typeof getEvents>>, TError = unknown>(
 eventID: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getEvents>>, TError, TData>, request?: SecondParameter<typeof orvalAxiosInstance>}
  
 ):  UseQueryResult<TData, TError> & { queryKey: QueryKey } {

  const queryOptions = getGetEventsQueryOptions(eventID,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

export const prefetchGetEventsQuery = async <TData = Awaited<ReturnType<typeof getEvents>>, TError = unknown>(
 queryClient: QueryClient, eventID: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getEvents>>, TError, TData>, request?: SecondParameter<typeof orvalAxiosInstance>}

  ): Promise<QueryClient> => {

  const queryOptions = getGetEventsQueryOptions(eventID,options)

  await queryClient.prefetchQuery(queryOptions);

  return queryClient;
}



/**
 * Edit
 */
export const patchEvents = (
    eventID: string,
    patchEventsBody: PatchEventsBody,
 options?: SecondParameter<typeof orvalAxiosInstance>,) => {
      
      
      return orvalAxiosInstance<ResEvent>(
      {url: `/api/v1/events/${eventID}`, method: 'PATCH',
      headers: {'Content-Type': 'application/json', },
      data: patchEventsBody
    },
      options);
    }
  


export const getPatchEventsMutationOptions = <TError = unknown,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchEvents>>, TError,{eventID: string;data: PatchEventsBody}, TContext>, request?: SecondParameter<typeof orvalAxiosInstance>}
): UseMutationOptions<Awaited<ReturnType<typeof patchEvents>>, TError,{eventID: string;data: PatchEventsBody}, TContext> => {

const mutationKey = ['patchEvents'];
const {mutation: mutationOptions, request: requestOptions} = options ?
      options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
      options
      : {...options, mutation: {...options.mutation, mutationKey}}
      : {mutation: { mutationKey, }, request: undefined};

      


      const mutationFn: MutationFunction<Awaited<ReturnType<typeof patchEvents>>, {eventID: string;data: PatchEventsBody}> = (props) => {
          const {eventID,data} = props ?? {};

          return  patchEvents(eventID,data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PatchEventsMutationResult = NonNullable<Awaited<ReturnType<typeof patchEvents>>>
    export type PatchEventsMutationBody = PatchEventsBody
    export type PatchEventsMutationError = unknown

    export const usePatchEvents = <TError = unknown,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchEvents>>, TError,{eventID: string;data: PatchEventsBody}, TContext>, request?: SecondParameter<typeof orvalAxiosInstance>}
 ): UseMutationResult<
        Awaited<ReturnType<typeof patchEvents>>,
        TError,
        {eventID: string;data: PatchEventsBody},
        TContext
      > => {

      const mutationOptions = getPatchEventsMutationOptions(options);

      return useMutation(mutationOptions);
    }
    /**
 * Delete
 */
export const deleteEvents = (
    eventID: string,
 options?: SecondParameter<typeof orvalAxiosInstance>,) => {
      
      
      return orvalAxiosInstance<void>(
      {url: `/api/v1/events/${eventID}`, method: 'DELETE'
    },
      options);
    }
  


export const getDeleteEventsMutationOptions = <TError = unknown,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteEvents>>, TError,{eventID: string}, TContext>, request?: SecondParameter<typeof orvalAxiosInstance>}
): UseMutationOptions<Awaited<ReturnType<typeof deleteEvents>>, TError,{eventID: string}, TContext> => {

const mutationKey = ['deleteEvents'];
const {mutation: mutationOptions, request: requestOptions} = options ?
      options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
      options
      : {...options, mutation: {...options.mutation, mutationKey}}
      : {mutation: { mutationKey, }, request: undefined};

      


      const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteEvents>>, {eventID: string}> = (props) => {
          const {eventID} = props ?? {};

          return  deleteEvents(eventID,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteEventsMutationResult = NonNullable<Awaited<ReturnType<typeof deleteEvents>>>
    
    export type DeleteEventsMutationError = unknown

    export const useDeleteEvents = <TError = unknown,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteEvents>>, TError,{eventID: string}, TContext>, request?: SecondParameter<typeof orvalAxiosInstance>}
 ): UseMutationResult<
        Awaited<ReturnType<typeof deleteEvents>>,
        TError,
        {eventID: string},
        TContext
      > => {

      const mutationOptions = getDeleteEventsMutationOptions(options);

      return useMutation(mutationOptions);
    }
    