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

export type CreateUserRequestBody = {
  email?: string;
  name?: string;
  password?: string;
  required?: {};
  role?: string;
  username?: string;
};

export type CreateUserOkResponse = User;

export type CreateUserErrorResponse = ResponseErrBadRequest;

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

export function createUser(props: CreateUserProps): Promise<CreateUserOkResponse> {
  return fetcher<CreateUserOkResponse, unknown, CreateUserRequestBody>({
    url: `/auth/create_user`,
    method: 'POST',
    ...props
  });
}

export type CreateUserMutationProps<T extends keyof CreateUserProps> = Omit<CreateUserProps, T> &
  Partial<Pick<CreateUserProps, T>>;

/**
 * This API is used to create a new user.
 */
export function useCreateUserMutation<T extends keyof CreateUserProps>(
  props: Pick<Partial<CreateUserProps>, T>,
  options?: Omit<
    UseMutationOptions<CreateUserOkResponse, CreateUserErrorResponse, CreateUserMutationProps<T>>,
    'mutationKey' | 'mutationFn'
  >
) {
  return useMutation<CreateUserOkResponse, CreateUserErrorResponse, CreateUserMutationProps<T>>(
    (mutateProps: CreateUserMutationProps<T>) => createUser({ ...props, ...mutateProps } as CreateUserProps),
    options
  );
}
