import { http } from './client'
import type { Device } from '@/types'

export const deviceApi = {
  /**
   * 获取设备列表
   */
  async getDevices() {
    return http.get<Device[]>('/devices')
  },

  /**
   * 获取设备详情
   */
  async getDevice(id: string) {
    return http.get<Device>(`/devices/${id}`)
  },

  /**
   * 更新设备名称
   */
  async updateDeviceName(id: string, deviceName: string) {
    return http.put<Device>(`/devices/${id}`, { deviceName })
  },

  /**
   * 删除设备
   */
  async deleteDevice(id: string) {
    return http.delete(`/devices/${id}`)
  },

  /**
   * 设置管理员设备
   */
  async setAdminDevice(id: string) {
    return http.put(`/devices/${id}/admin`)
  }
}

