import { apiClient } from './client';
import type { User, UserCreateInput, UserPatchInput } from './types';

export async function listUsers(): Promise<User[]> {
  const { data } = await apiClient.get<User[]>('/users');
  return data;
}

export async function createUser(input: UserCreateInput): Promise<User> {
  const { data } = await apiClient.post<User>('/users', input);
  return data;
}

export async function patchUser(id: number, input: UserPatchInput): Promise<User> {
  const { data } = await apiClient.patch<User>(`/users/${id}`, input);
  return data;
}

export async function deleteUser(id: number): Promise<void> {
  await apiClient.delete(`/users/${id}`);
}
