/**
 * Generated by orval v7.10.0 🍺
 * Do not edit manually.
 * Monitoring | v1
 * OpenAPI spec version: 1.0.0
 */
import {
  useMutation,
  useQuery
} from '@tanstack/react-query';
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseQueryResult,
  MutationFunction,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseMutationOptions,
  UseMutationResult,
  UseQueryOptions,
  UseQueryResult
} from '@tanstack/react-query';

import type {
  CallModel,
  CreateCallRequest,
  GetCallListParams,
  TableDataResponseModelOfCallModel,
  UpdateCallRequest
} from './client.schemas';

import { customClient } from '../services/http.service';





export const getCallList = (
    params?: GetCallListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfCallModel>(
      {url: `/api/calls`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetCallListQueryKey = (params?: GetCallListParams,) => {
    return [`/api/calls`, ...(params ? [params]: [])] as const;
    }

    
export const getGetCallListQueryOptions = <TData = Awaited<ReturnType<typeof getCallList>>, TError = unknown>(params?: GetCallListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCallList>>, TError, TData>>, }
) => {

const {query: queryOptions} = options ?? {};

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

  

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

      

      

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

export type GetCallListQueryResult = NonNullable<Awaited<ReturnType<typeof getCallList>>>
export type GetCallListQueryError = unknown


export function useGetCallList<TData = Awaited<ReturnType<typeof getCallList>>, TError = unknown>(
 params: undefined |  GetCallListParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCallList>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getCallList>>,
          TError,
          Awaited<ReturnType<typeof getCallList>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetCallList<TData = Awaited<ReturnType<typeof getCallList>>, TError = unknown>(
 params?: GetCallListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCallList>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getCallList>>,
          TError,
          Awaited<ReturnType<typeof getCallList>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetCallList<TData = Awaited<ReturnType<typeof getCallList>>, TError = unknown>(
 params?: GetCallListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCallList>>, TError, TData>>, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }

export function useGetCallList<TData = Awaited<ReturnType<typeof getCallList>>, TError = unknown>(
 params?: GetCallListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCallList>>, TError, TData>>, }
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetCallListQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const createCall = (
    createCallRequest: CreateCallRequest,
 signal?: AbortSignal
) => {
      
      
      return customClient<CallModel>(
      {url: `/api/calls`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createCallRequest, signal
    },
      );
    }
  


export const getCreateCallMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createCall>>, TError,{data: CreateCallRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof createCall>>, TError,{data: CreateCallRequest}, TContext> => {

const mutationKey = ['createCall'];
const {mutation: mutationOptions} = options ?
      options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
      options
      : {...options, mutation: {...options.mutation, mutationKey}}
      : {mutation: { mutationKey, }};

      


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

          return  createCall(data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateCallMutationResult = NonNullable<Awaited<ReturnType<typeof createCall>>>
    export type CreateCallMutationBody = CreateCallRequest
    export type CreateCallMutationError = string

    export const useCreateCall = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createCall>>, TError,{data: CreateCallRequest}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof createCall>>,
        TError,
        {data: CreateCallRequest},
        TContext
      > => {

      const mutationOptions = getCreateCallMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const getCall = (
    id: string,
 signal?: AbortSignal
) => {
      
      
      return customClient<CallModel>(
      {url: `/api/calls/${id}`, method: 'GET', signal
    },
      );
    }
  

export const getGetCallQueryKey = (id: string,) => {
    return [`/api/calls/${id}`] as const;
    }

    
export const getGetCallQueryOptions = <TData = Awaited<ReturnType<typeof getCall>>, TError = string>(id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCall>>, TError, TData>>, }
) => {

const {query: queryOptions} = options ?? {};

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

  

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

      

      

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

export type GetCallQueryResult = NonNullable<Awaited<ReturnType<typeof getCall>>>
export type GetCallQueryError = string


export function useGetCall<TData = Awaited<ReturnType<typeof getCall>>, TError = string>(
 id: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCall>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getCall>>,
          TError,
          Awaited<ReturnType<typeof getCall>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetCall<TData = Awaited<ReturnType<typeof getCall>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCall>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getCall>>,
          TError,
          Awaited<ReturnType<typeof getCall>>
        > , 'initialData'
      >, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetCall<TData = Awaited<ReturnType<typeof getCall>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCall>>, TError, TData>>, }
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }

export function useGetCall<TData = Awaited<ReturnType<typeof getCall>>, TError = string>(
 id: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCall>>, TError, TData>>, }
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetCallQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const updateCall = (
    id: string,
    updateCallRequest: UpdateCallRequest,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/calls/${id}`, method: 'PUT',
      headers: {'Content-Type': 'application/json', },
      data: updateCallRequest
    },
      );
    }
  


export const getUpdateCallMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateCall>>, TError,{id: string;data: UpdateCallRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof updateCall>>, TError,{id: string;data: UpdateCallRequest}, TContext> => {

const mutationKey = ['updateCall'];
const {mutation: mutationOptions} = options ?
      options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
      options
      : {...options, mutation: {...options.mutation, mutationKey}}
      : {mutation: { mutationKey, }};

      


      const mutationFn: MutationFunction<Awaited<ReturnType<typeof updateCall>>, {id: string;data: UpdateCallRequest}> = (props) => {
          const {id,data} = props ?? {};

          return  updateCall(id,data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type UpdateCallMutationResult = NonNullable<Awaited<ReturnType<typeof updateCall>>>
    export type UpdateCallMutationBody = UpdateCallRequest
    export type UpdateCallMutationError = string

    export const useUpdateCall = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateCall>>, TError,{id: string;data: UpdateCallRequest}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof updateCall>>,
        TError,
        {id: string;data: UpdateCallRequest},
        TContext
      > => {

      const mutationOptions = getUpdateCallMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    