/** * Generated by orval v7.21.0 🍺 * Do not edit manually. * Negodata Api Server * OpenAPI spec version: 0.1.0 */ import { useMutation, useQuery } from "@tanstack/react-query"; import type { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, MutationFunction, QueryClient, QueryFunction, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, } from "@tanstack/react-query"; import type { HTTPValidationError, ListCardsParams, ReqCreateCard, ReqUpdateCard, ResCard, ResCardList, ResDeleteCard, } from ".././model"; import { customFetch } from "../../mutator/custom-fetch"; /** * @summary ν˜‘μƒμΉ΄λ“œ λͺ©λ‘ */ export const listCards = (params?: ListCardsParams, signal?: AbortSignal) => { return customFetch({ url: `/v1/card/list`, method: "GET", params, signal, }); }; export const getListCardsQueryKey = (params?: ListCardsParams) => { return [`/v1/card/list`, ...(params ? [params] : [])] as const; }; export const getListCardsQueryOptions = < TData = Awaited>, TError = void | HTTPValidationError, >( params?: ListCardsParams, options?: { query?: Partial< UseQueryOptions>, TError, TData> >; }, ) => { const { query: queryOptions } = options ?? {}; const queryKey = queryOptions?.queryKey ?? getListCardsQueryKey(params); const queryFn: QueryFunction>> = ({ signal, }) => listCards(params, signal); return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< Awaited>, TError, TData > & { queryKey: DataTag }; }; export type ListCardsQueryResult = NonNullable< Awaited> >; export type ListCardsQueryError = void | HTTPValidationError; export function useListCards< TData = Awaited>, TError = void | HTTPValidationError, >( params: undefined | ListCardsParams, options: { query: Partial< UseQueryOptions>, TError, TData> > & Pick< DefinedInitialDataOptions< Awaited>, TError, Awaited> >, "initialData" >; }, queryClient?: QueryClient, ): DefinedUseQueryResult & { queryKey: DataTag; }; export function useListCards< TData = Awaited>, TError = void | HTTPValidationError, >( params?: ListCardsParams, options?: { query?: Partial< UseQueryOptions>, TError, TData> > & Pick< UndefinedInitialDataOptions< Awaited>, TError, Awaited> >, "initialData" >; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; }; export function useListCards< TData = Awaited>, TError = void | HTTPValidationError, >( params?: ListCardsParams, options?: { query?: Partial< UseQueryOptions>, TError, TData> >; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; }; /** * @summary ν˜‘μƒμΉ΄λ“œ λͺ©λ‘ */ export function useListCards< TData = Awaited>, TError = void | HTTPValidationError, >( params?: ListCardsParams, options?: { query?: Partial< UseQueryOptions>, TError, TData> >; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; } { const queryOptions = getListCardsQueryOptions(params, options); const query = useQuery(queryOptions, queryClient) as UseQueryResult< TData, TError > & { queryKey: DataTag }; query.queryKey = queryOptions.queryKey; return query; } /** * @summary ν˜‘μƒμΉ΄λ“œ 등둝 */ export const createCard = ( reqCreateCard: ReqCreateCard, signal?: AbortSignal, ) => { return customFetch({ url: `/v1/card/create`, method: "POST", headers: { "Content-Type": "application/json" }, data: reqCreateCard, signal, }); }; export const getCreateCardMutationOptions = < TError = void | HTTPValidationError, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { data: ReqCreateCard }, TContext >; }): UseMutationOptions< Awaited>, TError, { data: ReqCreateCard }, TContext > => { const mutationKey = ["createCard"]; const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } }; const mutationFn: MutationFunction< Awaited>, { data: ReqCreateCard } > = (props) => { const { data } = props ?? {}; return createCard(data); }; return { mutationFn, ...mutationOptions }; }; export type CreateCardMutationResult = NonNullable< Awaited> >; export type CreateCardMutationBody = ReqCreateCard; export type CreateCardMutationError = void | HTTPValidationError; /** * @summary ν˜‘μƒμΉ΄λ“œ 등둝 */ export const useCreateCard = < TError = void | HTTPValidationError, TContext = unknown, >( options?: { mutation?: UseMutationOptions< Awaited>, TError, { data: ReqCreateCard }, TContext >; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { data: ReqCreateCard }, TContext > => { const mutationOptions = getCreateCardMutationOptions(options); return useMutation(mutationOptions, queryClient); }; /** * @summary ν˜‘μƒμΉ΄λ“œ 쑰회 */ export const getCard = (cardId: string, signal?: AbortSignal) => { return customFetch({ url: `/v1/card/${cardId}`, method: "GET", signal, }); }; export const getGetCardQueryKey = (cardId?: string) => { return [`/v1/card/${cardId}`] as const; }; export const getGetCardQueryOptions = < TData = Awaited>, TError = void | HTTPValidationError, >( cardId: string, options?: { query?: Partial< UseQueryOptions>, TError, TData> >; }, ) => { const { query: queryOptions } = options ?? {}; const queryKey = queryOptions?.queryKey ?? getGetCardQueryKey(cardId); const queryFn: QueryFunction>> = ({ signal, }) => getCard(cardId, signal); return { queryKey, queryFn, enabled: !!cardId, ...queryOptions, } as UseQueryOptions>, TError, TData> & { queryKey: DataTag; }; }; export type GetCardQueryResult = NonNullable< Awaited> >; export type GetCardQueryError = void | HTTPValidationError; export function useGetCard< TData = Awaited>, TError = void | HTTPValidationError, >( cardId: string, options: { query: Partial< UseQueryOptions>, TError, TData> > & Pick< DefinedInitialDataOptions< Awaited>, TError, Awaited> >, "initialData" >; }, queryClient?: QueryClient, ): DefinedUseQueryResult & { queryKey: DataTag; }; export function useGetCard< TData = Awaited>, TError = void | HTTPValidationError, >( cardId: string, options?: { query?: Partial< UseQueryOptions>, TError, TData> > & Pick< UndefinedInitialDataOptions< Awaited>, TError, Awaited> >, "initialData" >; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; }; export function useGetCard< TData = Awaited>, TError = void | HTTPValidationError, >( cardId: string, options?: { query?: Partial< UseQueryOptions>, TError, TData> >; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; }; /** * @summary ν˜‘μƒμΉ΄λ“œ 쑰회 */ export function useGetCard< TData = Awaited>, TError = void | HTTPValidationError, >( cardId: string, options?: { query?: Partial< UseQueryOptions>, TError, TData> >; }, queryClient?: QueryClient, ): UseQueryResult & { queryKey: DataTag; } { const queryOptions = getGetCardQueryOptions(cardId, options); const query = useQuery(queryOptions, queryClient) as UseQueryResult< TData, TError > & { queryKey: DataTag }; query.queryKey = queryOptions.queryKey; return query; } /** * @summary ν˜‘μƒμΉ΄λ“œ μˆ˜μ • */ export const updateCard = (cardId: string, reqUpdateCard: ReqUpdateCard) => { return customFetch({ url: `/v1/card/update/${cardId}`, method: "PATCH", headers: { "Content-Type": "application/json" }, data: reqUpdateCard, }); }; export const getUpdateCardMutationOptions = < TError = void | HTTPValidationError, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { cardId: string; data: ReqUpdateCard }, TContext >; }): UseMutationOptions< Awaited>, TError, { cardId: string; data: ReqUpdateCard }, TContext > => { const mutationKey = ["updateCard"]; const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } }; const mutationFn: MutationFunction< Awaited>, { cardId: string; data: ReqUpdateCard } > = (props) => { const { cardId, data } = props ?? {}; return updateCard(cardId, data); }; return { mutationFn, ...mutationOptions }; }; export type UpdateCardMutationResult = NonNullable< Awaited> >; export type UpdateCardMutationBody = ReqUpdateCard; export type UpdateCardMutationError = void | HTTPValidationError; /** * @summary ν˜‘μƒμΉ΄λ“œ μˆ˜μ • */ export const useUpdateCard = < TError = void | HTTPValidationError, TContext = unknown, >( options?: { mutation?: UseMutationOptions< Awaited>, TError, { cardId: string; data: ReqUpdateCard }, TContext >; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { cardId: string; data: ReqUpdateCard }, TContext > => { const mutationOptions = getUpdateCardMutationOptions(options); return useMutation(mutationOptions, queryClient); }; /** * @summary ν˜‘μƒμΉ΄λ“œ μ‚­μ œ */ export const deleteCard = (cardId: string) => { return customFetch({ url: `/v1/card/delete/${cardId}`, method: "DELETE", }); }; export const getDeleteCardMutationOptions = < TError = void | HTTPValidationError, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { cardId: string }, TContext >; }): UseMutationOptions< Awaited>, TError, { cardId: string }, TContext > => { const mutationKey = ["deleteCard"]; const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } }; const mutationFn: MutationFunction< Awaited>, { cardId: string } > = (props) => { const { cardId } = props ?? {}; return deleteCard(cardId); }; return { mutationFn, ...mutationOptions }; }; export type DeleteCardMutationResult = NonNullable< Awaited> >; export type DeleteCardMutationError = void | HTTPValidationError; /** * @summary ν˜‘μƒμΉ΄λ“œ μ‚­μ œ */ export const useDeleteCard = < TError = void | HTTPValidationError, TContext = unknown, >( options?: { mutation?: UseMutationOptions< Awaited>, TError, { cardId: string }, TContext >; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { cardId: string }, TContext > => { const mutationOptions = getDeleteCardMutationOptions(options); return useMutation(mutationOptions, queryClient); };