/**
 * 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 {
  DeleteProductsParams,
  GetProductsParams,
  OrganizationProduct,
  OrganizationProductBody,
  PutProductsParams,
  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
 */
export type getProductsIdResponse200 = {
  data: Response
  status: 200
}
    
export type getProductsIdResponseSuccess = (getProductsIdResponse200) & {
  headers: Headers;
};
;

export type getProductsIdResponse = (getProductsIdResponseSuccess)

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


  

  return `/products/${id}`
}

export const getProductsId = async (id: string, options?: RequestInit): Promise<getProductsIdResponse> => {
  
  return useCustomClient<getProductsIdResponse>(getGetProductsIdUrl(id),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetProductsIdInfiniteQueryKey = (id?: string,) => {
    return [
    'infinite', `/products/${id}`
    ] as const;
    }

export const getGetProductsIdQueryKey = (id?: string,) => {
    return [
    `/products/${id}`
    ] as const;
    }

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

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

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

  

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

      

      

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

export type GetProductsIdInfiniteQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsId>>>
export type GetProductsIdInfiniteQueryError = ErrorType<unknown>


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

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

  const queryOptions = getGetProductsIdInfiniteQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

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

  ): Promise<QueryClient> => {

  const queryOptions = getGetProductsIdInfiniteQueryOptions(id,options)

  await queryClient.prefetchInfiniteQuery(queryOptions);

  return queryClient;
}



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

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

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

  

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

      

      

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

export type GetProductsIdQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsId>>>
export type GetProductsIdQueryError = ErrorType<unknown>


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

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

  const queryOptions = getGetProductsIdQueryOptions(id,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

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

  ): Promise<QueryClient> => {

  const queryOptions = getGetProductsIdQueryOptions(id,options)

  await queryClient.prefetchQuery(queryOptions);

  return queryClient;
}



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

export type putProductsIdResponse = (putProductsIdResponseSuccess)

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


  

  return `/products/${id}`
}

export const putProductsId = async (id: string,
    organizationProductBody: OrganizationProductBody, options?: RequestInit): Promise<putProductsIdResponse> => {
  
  return useCustomClient<putProductsIdResponse>(getPutProductsIdUrl(id),
  {      
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      organizationProductBody,)
  }
);}




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

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

          return  putProductsId(id,data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PutProductsIdMutationResult = NonNullable<Awaited<ReturnType<typeof putProductsId>>>
    export type PutProductsIdMutationBody = BodyType<OrganizationProductBody>
    export type PutProductsIdMutationError = ErrorType<unknown>

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

      const mutationOptions = getPutProductsIdMutationOptions(options);

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

export type deleteProductsIdResponse = (deleteProductsIdResponseSuccess)

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


  

  return `/products/${id}`
}

export const deleteProductsId = async (id: string, options?: RequestInit): Promise<deleteProductsIdResponse> => {
  
  return useCustomClient<deleteProductsIdResponse>(getDeleteProductsIdUrl(id),
  {      
    ...options,
    method: 'DELETE'
    
    
  }
);}




export const getDeleteProductsIdMutationOptions = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteProductsId>>, TError,{id: string}, TContext>, request?: SecondParameter<typeof useCustomClient>}
): UseMutationOptions<Awaited<ReturnType<typeof deleteProductsId>>, TError,{id: string}, TContext> => {

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

          return  deleteProductsId(id,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteProductsIdMutationResult = NonNullable<Awaited<ReturnType<typeof deleteProductsId>>>
    
    export type DeleteProductsIdMutationError = ErrorType<unknown>

    export const useDeleteProductsId = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteProductsId>>, TError,{id: string}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof deleteProductsId>>,
        TError,
        {id: string},
        TContext
      > => {

      const mutationOptions = getDeleteProductsIdMutationOptions(options);

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

export type getProductsResponse = (getProductsResponseSuccess)

export const getGetProductsUrl = (params?: GetProductsParams,) => {
  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 ? `/products?${stringifiedParams}` : `/products`
}

export const getProducts = async (params?: GetProductsParams, options?: RequestInit): Promise<getProductsResponse> => {
  
  return useCustomClient<getProductsResponse>(getGetProductsUrl(params),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetProductsInfiniteQueryKey = (params?: GetProductsParams,) => {
    return [
    'infinite', `/products`, ...(params ? [params]: [])
    ] as const;
    }

export const getGetProductsQueryKey = (params?: GetProductsParams,) => {
    return [
    `/products`, ...(params ? [params]: [])
    ] as const;
    }

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

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

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

  

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

      

      

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

export type GetProductsInfiniteQueryResult = NonNullable<Awaited<ReturnType<typeof getProducts>>>
export type GetProductsInfiniteQueryError = ErrorType<unknown>


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

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

  const queryOptions = getGetProductsInfiniteQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

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

  ): Promise<QueryClient> => {

  const queryOptions = getGetProductsInfiniteQueryOptions(params,options)

  await queryClient.prefetchInfiniteQuery(queryOptions);

  return queryClient;
}



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

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

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

  

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

      

      

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

export type GetProductsQueryResult = NonNullable<Awaited<ReturnType<typeof getProducts>>>
export type GetProductsQueryError = ErrorType<unknown>


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

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

  const queryOptions = getGetProductsQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

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

  ): Promise<QueryClient> => {

  const queryOptions = getGetProductsQueryOptions(params,options)

  await queryClient.prefetchQuery(queryOptions);

  return queryClient;
}



/**
 * Post
 */
export type postProductsResponse200 = {
  data: Response
  status: 200
}
    
export type postProductsResponseSuccess = (postProductsResponse200) & {
  headers: Headers;
};
;

export type postProductsResponse = (postProductsResponseSuccess)

export const getPostProductsUrl = () => {


  

  return `/products`
}

export const postProducts = async (organizationProduct: OrganizationProduct[], options?: RequestInit): Promise<postProductsResponse> => {
  
  return useCustomClient<postProductsResponse>(getPostProductsUrl(),
  {      
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      organizationProduct,)
  }
);}




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

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

          return  postProducts(data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PostProductsMutationResult = NonNullable<Awaited<ReturnType<typeof postProducts>>>
    export type PostProductsMutationBody = BodyType<OrganizationProduct[]>
    export type PostProductsMutationError = ErrorType<unknown>

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

      const mutationOptions = getPostProductsMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    /**
 * Put
 */
export type putProductsResponse200 = {
  data: Response
  status: 200
}
    
export type putProductsResponseSuccess = (putProductsResponse200) & {
  headers: Headers;
};
;

export type putProductsResponse = (putProductsResponseSuccess)

export const getPutProductsUrl = (params: PutProductsParams,) => {
  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 ? `/products?${stringifiedParams}` : `/products`
}

export const putProducts = async (organizationProductBody: OrganizationProductBody,
    params: PutProductsParams, options?: RequestInit): Promise<putProductsResponse> => {
  
  return useCustomClient<putProductsResponse>(getPutProductsUrl(params),
  {      
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      organizationProductBody,)
  }
);}




export const getPutProductsMutationOptions = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof putProducts>>, TError,{data: BodyType<OrganizationProductBody>;params: PutProductsParams}, TContext>, request?: SecondParameter<typeof useCustomClient>}
): UseMutationOptions<Awaited<ReturnType<typeof putProducts>>, TError,{data: BodyType<OrganizationProductBody>;params: PutProductsParams}, TContext> => {

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

          return  putProducts(data,params,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PutProductsMutationResult = NonNullable<Awaited<ReturnType<typeof putProducts>>>
    export type PutProductsMutationBody = BodyType<OrganizationProductBody>
    export type PutProductsMutationError = ErrorType<unknown>

    export const usePutProducts = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof putProducts>>, TError,{data: BodyType<OrganizationProductBody>;params: PutProductsParams}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof putProducts>>,
        TError,
        {data: BodyType<OrganizationProductBody>;params: PutProductsParams},
        TContext
      > => {

      const mutationOptions = getPutProductsMutationOptions(options);

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

export type deleteProductsResponse = (deleteProductsResponseSuccess)

export const getDeleteProductsUrl = (params: DeleteProductsParams,) => {
  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 ? `/products?${stringifiedParams}` : `/products`
}

export const deleteProducts = async (params: DeleteProductsParams, options?: RequestInit): Promise<deleteProductsResponse> => {
  
  return useCustomClient<deleteProductsResponse>(getDeleteProductsUrl(params),
  {      
    ...options,
    method: 'DELETE'
    
    
  }
);}




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

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

          return  deleteProducts(params,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteProductsMutationResult = NonNullable<Awaited<ReturnType<typeof deleteProducts>>>
    
    export type DeleteProductsMutationError = ErrorType<unknown>

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

      const mutationOptions = getDeleteProductsMutationOptions(options);

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

export type getProductsSlugSlugResponse = (getProductsSlugSlugResponseSuccess)

export const getGetProductsSlugSlugUrl = (slug: string,) => {


  

  return `/products/slug/${slug}`
}

export const getProductsSlugSlug = async (slug: string, options?: RequestInit): Promise<getProductsSlugSlugResponse> => {
  
  return useCustomClient<getProductsSlugSlugResponse>(getGetProductsSlugSlugUrl(slug),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetProductsSlugSlugInfiniteQueryKey = (slug?: string,) => {
    return [
    'infinite', `/products/slug/${slug}`
    ] as const;
    }

export const getGetProductsSlugSlugQueryKey = (slug?: string,) => {
    return [
    `/products/slug/${slug}`
    ] as const;
    }

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

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

  const queryKey =  queryOptions?.queryKey ?? getGetProductsSlugSlugInfiniteQueryKey(slug);

  

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

      

      

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

export type GetProductsSlugSlugInfiniteQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsSlugSlug>>>
export type GetProductsSlugSlugInfiniteQueryError = ErrorType<unknown>


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

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

  const queryOptions = getGetProductsSlugSlugInfiniteQueryOptions(slug,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

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

  ): Promise<QueryClient> => {

  const queryOptions = getGetProductsSlugSlugInfiniteQueryOptions(slug,options)

  await queryClient.prefetchInfiniteQuery(queryOptions);

  return queryClient;
}



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

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

  const queryKey =  queryOptions?.queryKey ?? getGetProductsSlugSlugQueryKey(slug);

  

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

      

      

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

export type GetProductsSlugSlugQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsSlugSlug>>>
export type GetProductsSlugSlugQueryError = ErrorType<unknown>


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

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

  const queryOptions = getGetProductsSlugSlugQueryOptions(slug,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

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

  ): Promise<QueryClient> => {

  const queryOptions = getGetProductsSlugSlugQueryOptions(slug,options)

  await queryClient.prefetchQuery(queryOptions);

  return queryClient;
}



