/**
 * 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 {
  DeleteFilesBody,
  PostFilesBody,
  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];



/**
 * Get all uploaded files
 */
export type getFilesResponse200 = {
  data: void
  status: 200
}
    
export type getFilesResponseSuccess = (getFilesResponse200) & {
  headers: Headers;
};
;

export type getFilesResponse = (getFilesResponseSuccess)

export const getGetFilesUrl = () => {


  

  return `/files`
}

export const getFiles = async ( options?: RequestInit): Promise<getFilesResponse> => {
  
  return useCustomClient<getFilesResponse>(getGetFilesUrl(),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetFilesInfiniteQueryKey = () => {
    return [
    'infinite', `/files`
    ] as const;
    }

export const getGetFilesQueryKey = () => {
    return [
    `/files`
    ] as const;
    }

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

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

  const queryKey =  queryOptions?.queryKey ?? getGetFilesInfiniteQueryKey();

  

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

      

      

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

export type GetFilesInfiniteQueryResult = NonNullable<Awaited<ReturnType<typeof getFiles>>>
export type GetFilesInfiniteQueryError = ErrorType<unknown>


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

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

  const queryOptions = getGetFilesInfiniteQueryOptions(options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

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

  ): Promise<QueryClient> => {

  const queryOptions = getGetFilesInfiniteQueryOptions(options)

  await queryClient.prefetchInfiniteQuery(queryOptions);

  return queryClient;
}



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

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

  const queryKey =  queryOptions?.queryKey ?? getGetFilesQueryKey();

  

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

      

      

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

export type GetFilesQueryResult = NonNullable<Awaited<ReturnType<typeof getFiles>>>
export type GetFilesQueryError = ErrorType<unknown>


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

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

  const queryOptions = getGetFilesQueryOptions(options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

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

  ): Promise<QueryClient> => {

  const queryOptions = getGetFilesQueryOptions(options)

  await queryClient.prefetchQuery(queryOptions);

  return queryClient;
}



/**
 * Upload image
 */
export type postFilesResponse200 = {
  data: Response
  status: 200
}
    
export type postFilesResponseSuccess = (postFilesResponse200) & {
  headers: Headers;
};
;

export type postFilesResponse = (postFilesResponseSuccess)

export const getPostFilesUrl = () => {


  

  return `/files`
}

export const postFiles = async (postFilesBody: PostFilesBody, options?: RequestInit): Promise<postFilesResponse> => {
    const formData = new FormData();
formData.append(`file`, postFilesBody.file)

  return useCustomClient<postFilesResponse>(getPostFilesUrl(),
  {      
    ...options,
    method: 'POST'
    ,
    body: 
      formData,
  }
);}




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

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

          return  postFiles(data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PostFilesMutationResult = NonNullable<Awaited<ReturnType<typeof postFiles>>>
    export type PostFilesMutationBody = BodyType<PostFilesBody>
    export type PostFilesMutationError = ErrorType<unknown>

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

      const mutationOptions = getPostFilesMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    /**
 * Delete uploaded file by relative path
 */
export type deleteFilesResponse200 = {
  data: void
  status: 200
}

export type deleteFilesResponse404 = {
  data: void
  status: 404
}
    
export type deleteFilesResponseSuccess = (deleteFilesResponse200) & {
  headers: Headers;
};
export type deleteFilesResponseError = (deleteFilesResponse404) & {
  headers: Headers;
};

export type deleteFilesResponse = (deleteFilesResponseSuccess | deleteFilesResponseError)

export const getDeleteFilesUrl = () => {


  

  return `/files`
}

export const deleteFiles = async (deleteFilesBody: DeleteFilesBody, options?: RequestInit): Promise<deleteFilesResponse> => {
  
  return useCustomClient<deleteFilesResponse>(getDeleteFilesUrl(),
  {      
    ...options,
    method: 'DELETE',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      deleteFilesBody,)
  }
);}




export const getDeleteFilesMutationOptions = <TError = ErrorType<void>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteFiles>>, TError,{data: BodyType<DeleteFilesBody>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
): UseMutationOptions<Awaited<ReturnType<typeof deleteFiles>>, TError,{data: BodyType<DeleteFilesBody>}, TContext> => {

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

          return  deleteFiles(data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteFilesMutationResult = NonNullable<Awaited<ReturnType<typeof deleteFiles>>>
    export type DeleteFilesMutationBody = BodyType<DeleteFilesBody>
    export type DeleteFilesMutationError = ErrorType<void>

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

      const mutationOptions = getDeleteFilesMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    