/**
 * Generated by orval v8.0.0-rc.0 🍺
 * Do not edit manually.
 * Backend Template
 * 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 {
  GetNewsletterSubscriptionParams,
  NewsletterSubscriptionMutate,
  NewsletterSubscriptionUpdate,
  PatchNewsletterSubscriptionId200,
  PostNewsletterSubscription200,
  ResponseGetAllData
} 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];



/**
 * Update seen status of a newsletter subscription email
 * @summary Update newsletter subscription status
 */
export type patchNewsletterSubscriptionIdResponse200 = {
  data: PatchNewsletterSubscriptionId200
  status: 200
}
    
export type patchNewsletterSubscriptionIdResponseSuccess = (patchNewsletterSubscriptionIdResponse200) & {
  headers: Headers;
};
;

export type patchNewsletterSubscriptionIdResponse = (patchNewsletterSubscriptionIdResponseSuccess)

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


  

  return `/newsletterSubscription/${id}`
}

export const patchNewsletterSubscriptionId = async (id: string,
    newsletterSubscriptionUpdate: NewsletterSubscriptionUpdate, options?: RequestInit): Promise<patchNewsletterSubscriptionIdResponse> => {
  
  return useCustomClient<patchNewsletterSubscriptionIdResponse>(getPatchNewsletterSubscriptionIdUrl(id),
  {      
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      newsletterSubscriptionUpdate,)
  }
);}




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

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

          return  patchNewsletterSubscriptionId(id,data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PatchNewsletterSubscriptionIdMutationResult = NonNullable<Awaited<ReturnType<typeof patchNewsletterSubscriptionId>>>
    export type PatchNewsletterSubscriptionIdMutationBody = BodyType<NewsletterSubscriptionUpdate>
    export type PatchNewsletterSubscriptionIdMutationError = ErrorType<unknown>

    /**
 * @summary Update newsletter subscription status
 */
export const usePatchNewsletterSubscriptionId = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchNewsletterSubscriptionId>>, TError,{id: string;data: BodyType<NewsletterSubscriptionUpdate>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof patchNewsletterSubscriptionId>>,
        TError,
        {id: string;data: BodyType<NewsletterSubscriptionUpdate>},
        TContext
      > => {

      const mutationOptions = getPatchNewsletterSubscriptionIdMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    /**
 * Delete a newsletter subscription email
 * @summary Delete newsletter subscription
 */
export type deleteNewsletterSubscriptionIdResponse200 = {
  data: void
  status: 200
}
    
export type deleteNewsletterSubscriptionIdResponseSuccess = (deleteNewsletterSubscriptionIdResponse200) & {
  headers: Headers;
};
;

export type deleteNewsletterSubscriptionIdResponse = (deleteNewsletterSubscriptionIdResponseSuccess)

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


  

  return `/newsletterSubscription/${id}`
}

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




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

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

          return  deleteNewsletterSubscriptionId(id,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type DeleteNewsletterSubscriptionIdMutationResult = NonNullable<Awaited<ReturnType<typeof deleteNewsletterSubscriptionId>>>
    
    export type DeleteNewsletterSubscriptionIdMutationError = ErrorType<unknown>

    /**
 * @summary Delete newsletter subscription
 */
export const useDeleteNewsletterSubscriptionId = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteNewsletterSubscriptionId>>, TError,{id: string}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof deleteNewsletterSubscriptionId>>,
        TError,
        {id: string},
        TContext
      > => {

      const mutationOptions = getDeleteNewsletterSubscriptionIdMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    /**
 * Retrieve newsletter subscription emails with pagination, filtering and sorting
 * @summary Get all newsletter subscriptions
 */
export type getNewsletterSubscriptionResponse200 = {
  data: ResponseGetAllData
  status: 200
}
    
export type getNewsletterSubscriptionResponseSuccess = (getNewsletterSubscriptionResponse200) & {
  headers: Headers;
};
;

export type getNewsletterSubscriptionResponse = (getNewsletterSubscriptionResponseSuccess)

export const getGetNewsletterSubscriptionUrl = (params?: GetNewsletterSubscriptionParams,) => {
  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 ? `/newsletterSubscription?${stringifiedParams}` : `/newsletterSubscription`
}

export const getNewsletterSubscription = async (params?: GetNewsletterSubscriptionParams, options?: RequestInit): Promise<getNewsletterSubscriptionResponse> => {
  
  return useCustomClient<getNewsletterSubscriptionResponse>(getGetNewsletterSubscriptionUrl(params),
  {      
    ...options,
    method: 'GET'
    
    
  }
);}





export const getGetNewsletterSubscriptionInfiniteQueryKey = (params?: GetNewsletterSubscriptionParams,) => {
    return [
    'infinite', `/newsletterSubscription`, ...(params ? [params]: [])
    ] as const;
    }

export const getGetNewsletterSubscriptionQueryKey = (params?: GetNewsletterSubscriptionParams,) => {
    return [
    `/newsletterSubscription`, ...(params ? [params]: [])
    ] as const;
    }

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

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

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

  

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

      

      

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

export type GetNewsletterSubscriptionInfiniteQueryResult = NonNullable<Awaited<ReturnType<typeof getNewsletterSubscription>>>
export type GetNewsletterSubscriptionInfiniteQueryError = ErrorType<unknown>


export function useGetNewsletterSubscriptionInfinite<TData = InfiniteData<Awaited<ReturnType<typeof getNewsletterSubscription>>>, TError = ErrorType<unknown>>(
 params: undefined |  GetNewsletterSubscriptionParams, options: { query:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getNewsletterSubscription>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getNewsletterSubscription>>,
          TError,
          Awaited<ReturnType<typeof getNewsletterSubscription>>
        > , 'initialData'
      >, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  DefinedUseInfiniteQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetNewsletterSubscriptionInfinite<TData = InfiniteData<Awaited<ReturnType<typeof getNewsletterSubscription>>>, TError = ErrorType<unknown>>(
 params?: GetNewsletterSubscriptionParams, options?: { query?:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getNewsletterSubscription>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getNewsletterSubscription>>,
          TError,
          Awaited<ReturnType<typeof getNewsletterSubscription>>
        > , 'initialData'
      >, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  UseInfiniteQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetNewsletterSubscriptionInfinite<TData = InfiniteData<Awaited<ReturnType<typeof getNewsletterSubscription>>>, TError = ErrorType<unknown>>(
 params?: GetNewsletterSubscriptionParams, options?: { query?:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getNewsletterSubscription>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  UseInfiniteQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
 * @summary Get all newsletter subscriptions
 */

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

  const queryOptions = getGetNewsletterSubscriptionInfiniteQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

/**
 * @summary Get all newsletter subscriptions
 */
export const prefetchGetNewsletterSubscriptionInfiniteQuery = async <TData = Awaited<ReturnType<typeof getNewsletterSubscription>>, TError = ErrorType<unknown>>(
 queryClient: QueryClient, params?: GetNewsletterSubscriptionParams, options?: { query?:Partial<UseInfiniteQueryOptions<Awaited<ReturnType<typeof getNewsletterSubscription>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}

  ): Promise<QueryClient> => {

  const queryOptions = getGetNewsletterSubscriptionInfiniteQueryOptions(params,options)

  await queryClient.prefetchInfiniteQuery(queryOptions);

  return queryClient;
}



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

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

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

  

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

      

      

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

export type GetNewsletterSubscriptionQueryResult = NonNullable<Awaited<ReturnType<typeof getNewsletterSubscription>>>
export type GetNewsletterSubscriptionQueryError = ErrorType<unknown>


export function useGetNewsletterSubscription<TData = Awaited<ReturnType<typeof getNewsletterSubscription>>, TError = ErrorType<unknown>>(
 params: undefined |  GetNewsletterSubscriptionParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getNewsletterSubscription>>, TError, TData>> & Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getNewsletterSubscription>>,
          TError,
          Awaited<ReturnType<typeof getNewsletterSubscription>>
        > , 'initialData'
      >, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetNewsletterSubscription<TData = Awaited<ReturnType<typeof getNewsletterSubscription>>, TError = ErrorType<unknown>>(
 params?: GetNewsletterSubscriptionParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getNewsletterSubscription>>, TError, TData>> & Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getNewsletterSubscription>>,
          TError,
          Awaited<ReturnType<typeof getNewsletterSubscription>>
        > , 'initialData'
      >, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useGetNewsletterSubscription<TData = Awaited<ReturnType<typeof getNewsletterSubscription>>, TError = ErrorType<unknown>>(
 params?: GetNewsletterSubscriptionParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getNewsletterSubscription>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient
  ):  UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
 * @summary Get all newsletter subscriptions
 */

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

  const queryOptions = getGetNewsletterSubscriptionQueryOptions(params,options)

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

  query.queryKey = queryOptions.queryKey ;

  return query;
}

/**
 * @summary Get all newsletter subscriptions
 */
export const prefetchGetNewsletterSubscriptionQuery = async <TData = Awaited<ReturnType<typeof getNewsletterSubscription>>, TError = ErrorType<unknown>>(
 queryClient: QueryClient, params?: GetNewsletterSubscriptionParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getNewsletterSubscription>>, TError, TData>>, request?: SecondParameter<typeof useCustomClient>}

  ): Promise<QueryClient> => {

  const queryOptions = getGetNewsletterSubscriptionQueryOptions(params,options)

  await queryClient.prefetchQuery(queryOptions);

  return queryClient;
}



/**
 * Register an email to receive information from the website
 * @summary Subscribe newsletter email
 */
export type postNewsletterSubscriptionResponse200 = {
  data: PostNewsletterSubscription200
  status: 200
}
    
export type postNewsletterSubscriptionResponseSuccess = (postNewsletterSubscriptionResponse200) & {
  headers: Headers;
};
;

export type postNewsletterSubscriptionResponse = (postNewsletterSubscriptionResponseSuccess)

export const getPostNewsletterSubscriptionUrl = () => {


  

  return `/newsletterSubscription`
}

export const postNewsletterSubscription = async (newsletterSubscriptionMutate: NewsletterSubscriptionMutate, options?: RequestInit): Promise<postNewsletterSubscriptionResponse> => {
  
  return useCustomClient<postNewsletterSubscriptionResponse>(getPostNewsletterSubscriptionUrl(),
  {      
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(
      newsletterSubscriptionMutate,)
  }
);}




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

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

          return  postNewsletterSubscription(data,requestOptions)
        }

        


  return  { mutationFn, ...mutationOptions }}

    export type PostNewsletterSubscriptionMutationResult = NonNullable<Awaited<ReturnType<typeof postNewsletterSubscription>>>
    export type PostNewsletterSubscriptionMutationBody = BodyType<NewsletterSubscriptionMutate>
    export type PostNewsletterSubscriptionMutationError = ErrorType<unknown>

    /**
 * @summary Subscribe newsletter email
 */
export const usePostNewsletterSubscription = <TError = ErrorType<unknown>,
    TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postNewsletterSubscription>>, TError,{data: BodyType<NewsletterSubscriptionMutate>}, TContext>, request?: SecondParameter<typeof useCustomClient>}
 , queryClient?: QueryClient): UseMutationResult<
        Awaited<ReturnType<typeof postNewsletterSubscription>>,
        TError,
        {data: BodyType<NewsletterSubscriptionMutate>},
        TContext
      > => {

      const mutationOptions = getPostNewsletterSubscriptionMutationOptions(options);

      return useMutation(mutationOptions, queryClient);
    }
    