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

class InspectionDeviceRepository {
  Future<ResponseModel<InspectionDeviceListBO>> getList({
    required int pageSize,
    required int pageNum,
    int? roomId,
    String? runStatus,
  }) {
    return DioRequest.instance.get<InspectionDeviceListBO>(
      '/app/device/inspection',
      queryParameters: {
        'pageSize': pageSize,
        'pageNum': pageNum,
        'roomId': roomId,
        'runStatus': runStatus,
      },
      fromJsonT: (data) =>
          InspectionDeviceListBO.fromJson(data as Map<String, dynamic>),
    );
  }

  Future<ResponseModel<DeviceDetailBO>> getDetail(int deviceId) {
    return DioRequest.instance.get<DeviceDetailBO>(
      '/app/device/detail',
      queryParameters: {'deviceId': deviceId},
      fromJsonT: (data) =>
          DeviceDetailBO.fromJson(data as Map<String, dynamic>),
    );
  }

  Future<ResponseModel<InspectionStartResultBO>> startInspection(
      Map<String, dynamic> params) {
    return DioRequest.instance.post<InspectionStartResultBO>(
      '/app/device/inspection/start',
      data: params,
      fromJsonT: (data) =>
          InspectionStartResultBO.fromJson(data as Map<String, dynamic>),
    );
  }
}