/**
 * Generated by orval v8.0.0-rc.0 🍺
 * Do not edit manually.
 * VCCI
 * Coded by Meu TEAM
 * OpenAPI spec version: 1.0.0
 */
import {
  useInfiniteQuery,
  useMutation,
  useQuery
} from '@tanstack/react-query';
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseInfiniteQueryResult,
  DefinedUseQueryResult,
  InfiniteData,
  MutationFunction,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseInfiniteQueryOptions,
  UseInfiniteQueryResult,
  UseMutationOptions,
  UseMutationResult,
  UseQueryOptions,
  UseQueryResult
} from '@tanstack/react-query';

import type {
  ApprovalRequest,
  Approvals,
  DeleteApprovalParams,
  GetApprovalParams,
  Response
} from '../models';

import { useCustomClient } from '../mutator/custom-client';
import type { ErrorType , BodyType } from '../mutator/custom-client';



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



/**
 * Put
 */
export type putApprovalIdResponse200 = {
  data: Response
  status: 200
}
    
export type putApprovalIdResponseSuccess = (putApprovalIdResponse200) & {
  headers: Headers;
};
;

export type putApprovalIdResponse = (putApprovalIdResponseSuccess)

export const getPutApprovalIdUrl = (id: string,) => {


  

  return `/approval/${id}`
}

export const putApprovalId = async (id: string,
    approvals: Approvals, options?: RequestInit): Promise<putApprovalIdResponse> => {
  
  return useCustomClient<putApprovalIdResponse>(getPutApprovalIdUrl(id),
  {      
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      approvals,)
  }
);}




export const getPutApprovalIdMutationOptions = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof putApprovalId>>, TError,{id: string;data: BodyType<Approvals>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
): UseMutationOptions<Awaited<ReturnType<typeof putApprovalId>>, TError,{id: string;data: BodyType<Approvals>}, TContext> => {

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

          return  putApprovalId(id,data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PutApprovalIdMutationResult = NonNullable<Awaited<ReturnType<typeof putApprovalId>>>
    export type PutApprovalIdMutationBody = BodyType<Approvals>
    export type PutApprovalIdMutationError = ErrorType<unknown>

    export const usePutApprovalId = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof putApprovalId>>, TError,{id: string;data: BodyType<Approvals>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof putApprovalId>>,
        TError,
        {id: string;data: BodyType<Approvals>},
        TContext
      > => {

      const mutationOptions = getPutApprovalIdMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    /**
 * Get
 */
export type getApprovalResponse200 = {
  data: Response
  status: 200
}
    
export type getApprovalResponseSuccess = (getApprovalResponse200) & {
  headers: Headers;
};
;

export type getApprovalResponse = (getApprovalResponseSuccess)

export const getGetApprovalUrl = (params?: GetApprovalParams,) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString())
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0 ? `/approval?${stringifiedParams}` : `/approval`
}

export const getApproval = async (params?: GetApprovalParams, options?: RequestInit): Promise<getApprovalResponse> => {
  
  return useCustomClient<getApprovalResponse>(getGetApprovalUrl(params),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetApprovalInfiniteQueryKey = (params?: GetApprovalParams,) => {
    return [
    'infinite', `/approval`, ...(params ? [params]: [])
    ] as const;
    }

export const getGetApprovalQueryKey = (params?: GetApprovalParams,) => {
    return [
    `/approval`, ...(params ? [params]: [])
    ] as const;
    }

    
export const getGetApprovalInfiniteQueryOptions = <TData = InfiniteData<Awaited<ReturnType<typeof getApproval>>>, TError = ErrorType<unknown>>(params?: GetApprovalParams, options?: { query?:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}
) => {

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

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

  

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

      

      

   return  { queryKey, queryFn,   retry: 3, retryDelay: 1000,  ...queryOptions} as UseInfiniteQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}

export type GetApprovalInfiniteQueryResult = NonNullable<Awaited<ReturnType<typeof getApproval>>>
export type GetApprovalInfiniteQueryError = ErrorType<unknown>


export function useGetApprovalInfinite<TData = InfiniteData<Awaited<ReturnType<typeof getApproval>>>, TError = ErrorType<unknown>>(
 params: undefined |  GetApprovalParams, options: { query:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getApproval>>,
          TError,
          Awaited<ReturnType<typeof getApproval>>
        > , 'initialData'
      >, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  DefinedUseInfiniteQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetApprovalInfinite<TData = InfiniteData<Awaited<ReturnType<typeof getApproval>>>, TError = ErrorType<unknown>>(
 params?: GetApprovalParams, options?: { query?:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getApproval>>,
          TError,
          Awaited<ReturnType<typeof getApproval>>
        > , 'initialData'
      >, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  UseInfiniteQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetApprovalInfinite<TData = InfiniteData<Awaited<ReturnType<typeof getApproval>>>, TError = ErrorType<unknown>>(
 params?: GetApprovalParams, options?: { query?:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  UseInfiniteQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }

export function useGetApprovalInfinite<TData = InfiniteData<Awaited<ReturnType<typeof getApproval>>>, TError = ErrorType<unknown>>(
 params?: GetApprovalParams, options?: { query?:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient 
 ):  UseInfiniteQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetApprovalInfiniteQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

export const prefetchGetApprovalInfiniteQuery = async <TData = Awaited<ReturnType<typeof getApproval>>, TError = ErrorType<unknown>>(
 queryClient: QueryClient, params?: GetApprovalParams, options?: { query?:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}

  ): Promise<QueryClient> => {

  const queryOptions = getGetApprovalInfiniteQueryOptions(params,options)

  await queryClient.prefetchInfiniteQuery(queryOptions);

  return queryClient;
}



export const getGetApprovalQueryOptions = <TData = Awaited<ReturnType<typeof getApproval>>, TError = ErrorType<unknown>>(params?: GetApprovalParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}
) => {

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

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

  

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

      

      

   return  { queryKey, queryFn,   retry: 3, retryDelay: 1000,  ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}

export type GetApprovalQueryResult = NonNullable<Awaited<ReturnType<typeof getApproval>>>
export type GetApprovalQueryError = ErrorType<unknown>


export function useGetApproval<TData = Awaited<ReturnType<typeof getApproval>>, TError = ErrorType<unknown>>(
 params: undefined |  GetApprovalParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getApproval>>,
          TError,
          Awaited<ReturnType<typeof getApproval>>
        > , 'initialData'
      >, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetApproval<TData = Awaited<ReturnType<typeof getApproval>>, TError = ErrorType<unknown>>(
 params?: GetApprovalParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getApproval>>,
          TError,
          Awaited<ReturnType<typeof getApproval>>
        > , 'initialData'
      >, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetApproval<TData = Awaited<ReturnType<typeof getApproval>>, TError = ErrorType<unknown>>(
 params?: GetApprovalParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }

export function useGetApproval<TData = Awaited<ReturnType<typeof getApproval>>, TError = ErrorType<unknown>>(
 params?: GetApprovalParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient 
 ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

  const queryOptions = getGetApprovalQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

export const prefetchGetApprovalQuery = async <TData = Awaited<ReturnType<typeof getApproval>>, TError = ErrorType<unknown>>(
 queryClient: QueryClient, params?: GetApprovalParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getApproval>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}

  ): Promise<QueryClient> => {

  const queryOptions = getGetApprovalQueryOptions(params,options)

  await queryClient.prefetchQuery(queryOptions);

  return queryClient;
}



/**
 * Create bulk approvals and send invitation emails with Word document attachments
 */
export type postApprovalResponse200 = {
  data: Response
  status: 200
}
    
export type postApprovalResponseSuccess = (postApprovalResponse200) & {
  headers: Headers;
};
;

export type postApprovalResponse = (postApprovalResponseSuccess)

export const getPostApprovalUrl = () => {


  

  return `/approval`
}

export const postApproval = async (approvalRequest: ApprovalRequest, options?: RequestInit): Promise<postApprovalResponse> => {
  
  return useCustomClient<postApprovalResponse>(getPostApprovalUrl(),
  {      
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      approvalRequest,)
  }
);}




export const getPostApprovalMutationOptions = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postApproval>>, TError,{data: BodyType<ApprovalRequest>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
): UseMutationOptions<Awaited<ReturnType<typeof postApproval>>, TError,{data: BodyType<ApprovalRequest>}, TContext> => {

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

          return  postApproval(data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PostApprovalMutationResult = NonNullable<Awaited<ReturnType<typeof postApproval>>>
    export type PostApprovalMutationBody = BodyType<ApprovalRequest>
    export type PostApprovalMutationError = ErrorType<unknown>

    export const usePostApproval = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postApproval>>, TError,{data: BodyType<ApprovalRequest>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof postApproval>>,
        TError,
        {data: BodyType<ApprovalRequest>},
        TContext
      > => {

      const mutationOptions = getPostApprovalMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    /**
 * Delete
 */
export type deleteApprovalResponse200 = {
  data: Response
  status: 200
}
    
export type deleteApprovalResponseSuccess = (deleteApprovalResponse200) & {
  headers: Headers;
};
;

export type deleteApprovalResponse = (deleteApprovalResponseSuccess)

export const getDeleteApprovalUrl = (params: DeleteApprovalParams,) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString())
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0 ? `/approval?${stringifiedParams}` : `/approval`
}

export const deleteApproval = async (params: DeleteApprovalParams, options?: RequestInit): Promise<deleteApprovalResponse> => {
  
  return useCustomClient<deleteApprovalResponse>(getDeleteApprovalUrl(params),
  {      
    ...options,
    method: 'DELETE'
    
    
  }
);}




export const getDeleteApprovalMutationOptions = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteApproval>>, TError,{params: DeleteApprovalParams}, TContext>, request?: SecondParameter<typeof useCustomClient>}
): UseMutationOptions<Awaited<ReturnType<typeof deleteApproval>>, TError,{params: DeleteApprovalParams}, TContext> => {

const mutationKey = ['deleteApproval'];
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 deleteApproval>>, {params: DeleteApprovalParams}> = (props) => {
          const {params} = props ?? {};

          return  deleteApproval(params,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteApprovalMutationResult = NonNullable<Awaited<ReturnType<typeof deleteApproval>>>
    
    export type DeleteApprovalMutationError = ErrorType<unknown>

    export const useDeleteApproval = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteApproval>>, TError,{params: DeleteApprovalParams}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof deleteApproval>>,
        TError,
        {params: DeleteApprovalParams},
        TContext
      > => {

      const mutationOptions = getDeleteApprovalMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    /**
 * Post
 */
export type postApprovalMailResponse200 = {
  data: Response
  status: 200
}
    
export type postApprovalMailResponseSuccess = (postApprovalMailResponse200) & {
  headers: Headers;
};
;

export type postApprovalMailResponse = (postApprovalMailResponseSuccess)

export const getPostApprovalMailUrl = () => {


  

  return `/approval/mail`
}

export const postApprovalMail = async (approvals: Approvals[], options?: RequestInit): Promise<postApprovalMailResponse> => {
  
  return useCustomClient<postApprovalMailResponse>(getPostApprovalMailUrl(),
  {      
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      approvals,)
  }
);}




export const getPostApprovalMailMutationOptions = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postApprovalMail>>, TError,{data: BodyType<Approvals[]>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
): UseMutationOptions<Awaited<ReturnType<typeof postApprovalMail>>, TError,{data: BodyType<Approvals[]>}, TContext> => {

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

          return  postApprovalMail(data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PostApprovalMailMutationResult = NonNullable<Awaited<ReturnType<typeof postApprovalMail>>>
    export type PostApprovalMailMutationBody = BodyType<Approvals[]>
    export type PostApprovalMailMutationError = ErrorType<unknown>

    export const usePostApprovalMail = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postApprovalMail>>, TError,{data: BodyType<Approvals[]>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof postApprovalMail>>,
        TError,
        {data: BodyType<Approvals[]>},
        TContext
      > => {

      const mutationOptions = getPostApprovalMailMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    