/**
 * 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 {
  CreateResponsiblePersonRequest,
  GetResponsiblePersonListParams,
  ResponsiblePersonModel,
  TableDataResponseModelOfResponsiblePersonModel,
  UpdateResponsiblePersonRequest
} from './client.schemas';

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





export const getResponsiblePersonList = (
    params?: GetResponsiblePersonListParams,
 signal?: AbortSignal
) => {
      
      
      return customClient<TableDataResponseModelOfResponsiblePersonModel>(
      {url: `/api/responsible-persons`, method: 'GET',
        params, signal
    },
      );
    }
  

export const getGetResponsiblePersonListQueryKey = (params?: GetResponsiblePersonListParams,) => {
    return [`/api/responsible-persons`, ...(params ? [params]: [])] as const;
    }

    
export const getGetResponsiblePersonListQueryOptions = <TData = Awaited<ReturnType<typeof getResponsiblePersonList>>, TError = unknown>(params?: GetResponsiblePersonListParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getResponsiblePersonList>>, TError, TData>>, }
) => {

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

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

  

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

      

      

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

export type GetResponsiblePersonListQueryResult = NonNullable<Awaited<ReturnType<typeof getResponsiblePersonList>>>
export type GetResponsiblePersonListQueryError = unknown


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

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

  const queryOptions = getGetResponsiblePersonListQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const createResponsiblePerson = (
    createResponsiblePersonRequest: CreateResponsiblePersonRequest,
 signal?: AbortSignal
) => {
      
      
      return customClient<ResponsiblePersonModel>(
      {url: `/api/responsible-persons`, method: 'POST',
      headers: {'Content-Type': 'application/json', },
      data: createResponsiblePersonRequest, signal
    },
      );
    }
  


export const getCreateResponsiblePersonMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createResponsiblePerson>>, TError,{data: CreateResponsiblePersonRequest}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof createResponsiblePerson>>, TError,{data: CreateResponsiblePersonRequest}, TContext> => {

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

          return  createResponsiblePerson(data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type CreateResponsiblePersonMutationResult = NonNullable<Awaited<ReturnType<typeof createResponsiblePerson>>>
    export type CreateResponsiblePersonMutationBody = CreateResponsiblePersonRequest
    export type CreateResponsiblePersonMutationError = string

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

      const mutationOptions = getCreateResponsiblePersonMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const getResponsiblePerson = (
    id: string,
 signal?: AbortSignal
) => {
      
      
      return customClient<ResponsiblePersonModel>(
      {url: `/api/responsible-persons/${id}`, method: 'GET', signal
    },
      );
    }
  

export const getGetResponsiblePersonQueryKey = (id: string,) => {
    return [`/api/responsible-persons/${id}`] as const;
    }

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

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

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

  

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

      

      

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

export type GetResponsiblePersonQueryResult = NonNullable<Awaited<ReturnType<typeof getResponsiblePerson>>>
export type GetResponsiblePersonQueryError = string


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

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

  const queryOptions = getGetResponsiblePersonQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}



export const updateResponsiblePerson = (
    id: string,
    updateResponsiblePersonRequest: UpdateResponsiblePersonRequest,
 ) => {
      
      
      return customClient<ResponsiblePersonModel>(
      {url: `/api/responsible-persons/${id}`, method: 'PUT',
      headers: {'Content-Type': 'application/json', },
      data: updateResponsiblePersonRequest
    },
      );
    }
  


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

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

          return  updateResponsiblePerson(id,data,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type UpdateResponsiblePersonMutationResult = NonNullable<Awaited<ReturnType<typeof updateResponsiblePerson>>>
    export type UpdateResponsiblePersonMutationBody = UpdateResponsiblePersonRequest
    export type UpdateResponsiblePersonMutationError = string

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

      const mutationOptions = getUpdateResponsiblePersonMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    export const deleteResponsiblePerson = (
    id: string,
 ) => {
      
      
      return customClient<void>(
      {url: `/api/responsible-persons/${id}`, method: 'DELETE'
    },
      );
    }
  


export const getDeleteResponsiblePersonMutationOptions = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteResponsiblePerson>>, TError,{id: string}, TContext>, }
): UseMutationOptions<Awaited<ReturnType<typeof deleteResponsiblePerson>>, TError,{id: string}, TContext> => {

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

          return  deleteResponsiblePerson(id,)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteResponsiblePersonMutationResult = NonNullable<Awaited<ReturnType<typeof deleteResponsiblePerson>>>
    
    export type DeleteResponsiblePersonMutationError = string

    export const useDeleteResponsiblePerson = <TError = string,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteResponsiblePerson>>, TError,{id: string}, TContext>, }
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof deleteResponsiblePerson>>,
        TError,
        {id: string},
        TContext
      > => {

      const mutationOptions = getDeleteResponsiblePersonMutationOptions(options);

      return useMutation(mutationOptions , queryClient);
    }
    