mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
push ac batch control
This commit is contained in:
@ -65,6 +65,31 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> deviceBatchControl(
|
||||
List<String> uuids, String code, dynamic value) async {
|
||||
try {
|
||||
final body = {
|
||||
'devicesUuid': uuids,
|
||||
'code': code,
|
||||
'value': value,
|
||||
};
|
||||
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.deviceBatchControl,
|
||||
body: body,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return json['success'] ?? false;
|
||||
},
|
||||
);
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||
String gatewayId) async {
|
||||
final response = await HTTPService().get(
|
||||
@ -95,7 +120,23 @@ class DevicesManagementApi {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<DeviceReport> getDeviceReports(String uuid, String code,
|
||||
static Future<DeviceReport> getDeviceReports(
|
||||
String uuid,
|
||||
String code,
|
||||
) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getDeviceLogs
|
||||
.replaceAll('{uuid}', uuid)
|
||||
.replaceAll('{code}', code),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceReport.fromJson(json);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<DeviceReport> getDeviceReportsByDate(String uuid, String code,
|
||||
[String? from, String? to]) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getDeviceLogsByDate
|
||||
@ -110,4 +151,28 @@ class DevicesManagementApi {
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<DeviceStatus> getBatchStatus(List<String> uuids) async {
|
||||
try {
|
||||
final queryParameters = {
|
||||
'devicesUuid': uuids.join(','),
|
||||
};
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getBatchStatus,
|
||||
queryParameters: queryParameters,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceStatus.fromJson(json['status']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching $e');
|
||||
return DeviceStatus(
|
||||
productUuid: '',
|
||||
productType: '',
|
||||
status: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user