/**
 * 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 {
  CheckListTemplateModel,
  CreateCheckListTemplateRequest,
  GetCheckListTemplateListParams,
  TableDataResponseModelOfCheckListTemplateModel,
  UpdateCheckListTemplateRequest
} from './client.schemas';

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





export const createCheckListTemplate = (
    createCheckListTemplateRequest: CreateCheckListTemplateRequest,
 signal?: AbortSignal
) => {
      
      
      return customClient<CheckListTemplateModel>(
      {url: `/api/check-list-templates`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createCheckListTemplateRequest, signal
    },
      );
    }
  


export const getCreateCheckListTemplateMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createCheckListTemplate>>, TError,{data: CreateCheckListTemplateRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof createCheckListTemplate>>, TError,{data: CreateCheckListTemplateRequest}, TContext> => {

const mutationKey = ['createCheckListTemplate'];
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 createCheckListTemplate>>, {data: CreateCheckListTemplateRequest}> = (props) => {
          const {data} = props ?? {};

          return  createCheckListTemplate(data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateCheckListTemplateMutationResult = NonNullable<Awaited<ReturnType<typeof createCheckListTemplate>>>
    export type CreateCheckListTemplateMutationBody = CreateCheckListTemplateRequest
    export type CreateCheckListTemplateMutationError = string

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

      const mutationOptions = getCreateCheckListTemplateMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const getCheckListTemplateList = (
    params?: GetCheckListTemplateListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfCheckListTemplateModel>(
      {url: `/api/check-list-templates`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetCheckListTemplateListQueryKey = (params?: GetCheckListTemplateListParams,) => {
    return [`/api/check-list-templates`, ...(params ? [params]: [])] as const;
    }

    
export const getGetCheckListTemplateListQueryOptions = <TData = Awaited<ReturnType<typeof getCheckListTemplateList>>, TError = unknown>(params?: GetCheckListTemplateListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCheckListTemplateList>>, TError, TData>>, }
) => {

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

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

  

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

      

      

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

export type GetCheckListTemplateListQueryResult = NonNullable<Awaited<ReturnType<typeof getCheckListTemplateList>>>
export type GetCheckListTemplateListQueryError = unknown


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

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

  const queryOptions = getGetCheckListTemplateListQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const updateCheckListTemplate = (
    id: string,
    updateCheckListTemplateRequest: UpdateCheckListTemplateRequest,
 ) => {
      
      
      return customClient<CheckListTemplateModel>(
      {url: `/api/check-list-templates/${id}`, method: 'PUT',
      headers: {'Content-Type': 'application/json', },
      data: updateCheckListTemplateRequest
    },
      );
    }
  


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

const mutationKey = ['updateCheckListTemplate'];
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 updateCheckListTemplate>>, {id: string;data: UpdateCheckListTemplateRequest}> = (props) => {
          const {id,data} = props ?? {};

          return  updateCheckListTemplate(id,data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type UpdateCheckListTemplateMutationResult = NonNullable<Awaited<ReturnType<typeof updateCheckListTemplate>>>
    export type UpdateCheckListTemplateMutationBody = UpdateCheckListTemplateRequest
    export type UpdateCheckListTemplateMutationError = string

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

      const mutationOptions = getUpdateCheckListTemplateMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const getCheckListTemplateById = (
    id: string,
 signal?: AbortSignal
) => {
      
      
      return customClient<CheckListTemplateModel>(
      {url: `/api/check-list-templates/${id}`, method: 'GET', signal
    },
      );
    }
  

export const getGetCheckListTemplateByIdQueryKey = (id: string,) => {
    return [`/api/check-list-templates/${id}`] as const;
    }

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

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

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

  

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

      

      

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

export type GetCheckListTemplateByIdQueryResult = NonNullable<Awaited<ReturnType<typeof getCheckListTemplateById>>>
export type GetCheckListTemplateByIdQueryError = unknown


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

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

  const queryOptions = getGetCheckListTemplateByIdQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



