import '../utils/http/response_model.dart';
import '../utils/http/dio_request.dart';
import '../models/bo/device_control_bo.dart';

class DeviceControlRepository {
  /// 获取设备控制详情
  Future<ResponseModel<DeviceControlBO>> getDetail({required int deviceId}) {
    return DioRequest.instance.get<DeviceControlBO>(
      '/app/device/control/detail',
      queryParameters: {'deviceId': deviceId},
      fromJsonT: (data) =>
          DeviceControlBO.fromJson(data as Map<String, dynamic>),
    );
  }

  /// 远程送电
  Future<ResponseModel<Map<String, dynamic>>> powerOn({required int deviceId}) {
    return DioRequest.instance.post<Map<String, dynamic>>(
      // '/app/device/control/powerOn',
      '/app/room/device/power/single/on',
      data: {'deviceId': deviceId},
    );
  }

  /// 远程断电
  Future<ResponseModel<Map<String, dynamic>>> powerOff({required int deviceId}) {
    return DioRequest.instance.post<Map<String, dynamic>>(
      // '/app/device/control/powerOff',
      '/app/room/device/power/single/off',
      data: {'deviceId': deviceId},
    );
  }
}