/** * Generated by orval v7.17.0 🍺 * Do not edit manually. * OpenAPI spec version: 0.0.0 */ import { useMutation } from "@tanstack/react-query"; import type { MutationFunction, QueryClient, UseMutationOptions, UseMutationResult, } from "@tanstack/react-query"; import type { CustomTokenObtainPair } from "./models"; import { publicMutator } from "../../publicClient"; /** * Authenticate user and obtain JWT access and refresh tokens. You can use either email or username. * @summary Obtain JWT access and refresh tokens (cookie-based) */ export const apiAccountLoginCreate = ( customTokenObtainPair: CustomTokenObtainPair, signal?: AbortSignal, ) => { return publicMutator({ url: `/api/account/login/`, method: "POST", headers: { "Content-Type": "application/json" }, data: customTokenObtainPair, signal, }); }; export const getApiAccountLoginCreateMutationOptions = < TError = void, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, { data: CustomTokenObtainPair }, TContext >; }): UseMutationOptions< Awaited>, TError, { data: CustomTokenObtainPair }, TContext > => { const mutationKey = ["apiAccountLoginCreate"]; 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: CustomTokenObtainPair } > = (props) => { const { data } = props ?? {}; return apiAccountLoginCreate(data); }; return { mutationFn, ...mutationOptions }; }; export type ApiAccountLoginCreateMutationResult = NonNullable< Awaited> >; export type ApiAccountLoginCreateMutationBody = CustomTokenObtainPair; export type ApiAccountLoginCreateMutationError = void; /** * @summary Obtain JWT access and refresh tokens (cookie-based) */ export const useApiAccountLoginCreate = ( options?: { mutation?: UseMutationOptions< Awaited>, TError, { data: CustomTokenObtainPair }, TContext >; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, { data: CustomTokenObtainPair }, TContext > => { const mutationOptions = getApiAccountLoginCreateMutationOptions(options); return useMutation(mutationOptions, queryClient); }; /** * Logs out the user by deleting access and refresh token cookies. * @summary Logout user (delete access and refresh token cookies) */ export const apiAccountLogoutCreate = (signal?: AbortSignal) => { return publicMutator({ url: `/api/account/logout/`, method: "POST", signal, }); }; export const getApiAccountLogoutCreateMutationOptions = < TError = unknown, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, void, TContext >; }): UseMutationOptions< Awaited>, TError, void, TContext > => { const mutationKey = ["apiAccountLogoutCreate"]; 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>, void > = () => { return apiAccountLogoutCreate(); }; return { mutationFn, ...mutationOptions }; }; export type ApiAccountLogoutCreateMutationResult = NonNullable< Awaited> >; export type ApiAccountLogoutCreateMutationError = unknown; /** * @summary Logout user (delete access and refresh token cookies) */ export const useApiAccountLogoutCreate = ( options?: { mutation?: UseMutationOptions< Awaited>, TError, void, TContext >; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, void, TContext > => { const mutationOptions = getApiAccountLogoutCreateMutationOptions(options); return useMutation(mutationOptions, queryClient); }; /** * Refresh JWT access and refresh tokens using the refresh token stored in cookie. * @summary Refresh JWT token using cookie */ export const apiAccountTokenRefreshCreate = (signal?: AbortSignal) => { return publicMutator({ url: `/api/account/token/refresh/`, method: "POST", signal, }); }; export const getApiAccountTokenRefreshCreateMutationOptions = < TError = void, TContext = unknown, >(options?: { mutation?: UseMutationOptions< Awaited>, TError, void, TContext >; }): UseMutationOptions< Awaited>, TError, void, TContext > => { const mutationKey = ["apiAccountTokenRefreshCreate"]; 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>, void > = () => { return apiAccountTokenRefreshCreate(); }; return { mutationFn, ...mutationOptions }; }; export type ApiAccountTokenRefreshCreateMutationResult = NonNullable< Awaited> >; export type ApiAccountTokenRefreshCreateMutationError = void; /** * @summary Refresh JWT token using cookie */ export const useApiAccountTokenRefreshCreate = < TError = void, TContext = unknown, >( options?: { mutation?: UseMutationOptions< Awaited>, TError, void, TContext >; }, queryClient?: QueryClient, ): UseMutationResult< Awaited>, TError, void, TContext > => { const mutationOptions = getApiAccountTokenRefreshCreateMutationOptions(options); return useMutation(mutationOptions, queryClient); };