import apiClient from './client'
import type { DeviceTypeResponse, DeviceTypeCreate } from '@/types'

export const deviceTypesApi = {
  async list(): Promise<DeviceTypeResponse[]> {
    const response = await apiClient.get<DeviceTypeResponse[]>('/device-types/')
    return response.data
  },

  async create(data: DeviceTypeCreate): Promise<DeviceTypeResponse> {
    const response = await apiClient.post<DeviceTypeResponse>('/device-types/', data)
    return response.data
  },

  async update(id: string, data: Partial<DeviceTypeCreate>): Promise<DeviceTypeResponse> {
    const response = await apiClient.put<DeviceTypeResponse>(`/device-types/${id}`, data)
    return response.data
  },

  async remove(id: string): Promise<void> {
    await apiClient.delete(`/device-types/${id}`)
  },
}
