push ac batch control

This commit is contained in:
ashrafzarkanisala
2024-09-18 12:27:00 +03:00
parent 7c28012d79
commit abb0a58468
26 changed files with 516 additions and 66 deletions

View File

@ -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: [],
);
}
}
}