/* 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 { RemoveApiTokenResponse } from '../schemas/RemoveApiTokenResponse';
import type { ErrorModel } from '../schemas/ErrorModel';
import { fetcher, FetcherOptions } from 'services/fetcher';

export type RemoveApiTokenRequestBody = {
  token: string;
};

export type RemoveApiTokenOkResponse = RemoveApiTokenResponse;

export type RemoveApiTokenErrorResponse = ErrorModel;

export interface RemoveApiTokenProps extends Omit<FetcherOptions<unknown, RemoveApiTokenRequestBody>, 'url'> {
  body: RemoveApiTokenRequestBody;
}

export function removeApiToken(props: RemoveApiTokenProps): Promise<RemoveApiTokenOkResponse> {
  return fetcher<RemoveApiTokenOkResponse, unknown, RemoveApiTokenRequestBody>({
    url: `/auth/remove_token`,
    method: 'POST',
    ...props
  });
}

export type RemoveApiTokenMutationProps<T extends keyof RemoveApiTokenProps> = Omit<RemoveApiTokenProps, T> &
  Partial<Pick<RemoveApiTokenProps, T>>;

/**
 * This API is used to delete api-token for a user
 */
export function useRemoveApiTokenMutation<T extends keyof RemoveApiTokenProps>(
  props: Pick<Partial<RemoveApiTokenProps>, T>,
  options?: Omit<
    UseMutationOptions<RemoveApiTokenOkResponse, RemoveApiTokenErrorResponse, RemoveApiTokenMutationProps<T>>,
    'mutationKey' | 'mutationFn'
  >
) {
  return useMutation<RemoveApiTokenOkResponse, RemoveApiTokenErrorResponse, RemoveApiTokenMutationProps<T>>(
    (mutateProps: RemoveApiTokenMutationProps<T>) =>
      removeApiToken({ ...props, ...mutateProps } as RemoveApiTokenProps),
    options
  );
}
