/* eslint-disable */
// This code is autogenerated using @harnessio/oats-cli.
// Please do not modify this code directly.
import { useMutation, UseMutationOptions } from '@tanstack/react-query';

import type { LogoutResponse } from '../schemas/LogoutResponse';
import type { ErrorModel } from '../schemas/ErrorModel';
import { fetcher, FetcherOptions } from 'services/fetcher';

export type LogoutOkResponse = LogoutResponse;

export type LogoutErrorResponse = ErrorModel;

export interface LogoutProps extends Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export function logout(props: LogoutProps): Promise<LogoutOkResponse> {
  return fetcher<LogoutOkResponse, unknown, unknown>({
    url: `/auth/logout`,
    method: 'POST',
    ...props
  });
}

export type LogoutMutationProps<T extends keyof LogoutProps> = Omit<LogoutProps, T> & Partial<Pick<LogoutProps, T>>;

/**
 * This API is used to logout into auth server.
 */
export function useLogoutMutation<T extends keyof LogoutProps>(
  props: Pick<Partial<LogoutProps>, T>,
  options?: Omit<
    UseMutationOptions<LogoutOkResponse, LogoutErrorResponse, LogoutMutationProps<T>>,
    'mutationKey' | 'mutationFn'
  >
) {
  return useMutation<LogoutOkResponse, LogoutErrorResponse, LogoutMutationProps<T>>(
    (mutateProps: LogoutMutationProps<T>) => logout({ ...props, ...mutateProps } as LogoutProps),
    options
  );
}
