Refactor device_info_model.dart and devices_api.dart

This commit is contained in:
mohammad
2025-04-28 15:59:10 +03:00
parent bde418e52a
commit 6a27f863c3
2 changed files with 10 additions and 8 deletions

View File

@ -102,7 +102,8 @@ class DevicesAPI {
static Future<Map<String, dynamic>> getPowerClampStatus(
String deviceId) async {
final response = await _httpService.get(
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{deviceUuid}', deviceId),
path: ApiEndpoints.deviceFunctionsStatus
.replaceAll('{deviceUuid}', deviceId),
showServerMessage: false,
expectedResponseModel: (json) {
return json;
@ -144,7 +145,7 @@ class DevicesAPI {
path: ApiEndpoints.deviceScene.replaceAll('{deviceUuid}', deviceId),
showServerMessage: false,
expectedResponseModel: (json) {
return json;
return json['data'];
});
return response;
}
@ -592,11 +593,12 @@ class DevicesAPI {
return <DeviceModel>[];
}
final result = <DeviceModel>[];
for (final device in data) {
final mappedDevice = DeviceModel.fromJson(device);
if (mappedDevice.productType?.name != DeviceType.FlushMountedSensor.name) {
result.add(mappedDevice);
}
for (final device in data) {
final mappedDevice = DeviceModel.fromJson(device);
if (mappedDevice.productType?.name !=
DeviceType.FlushMountedSensor.name) {
result.add(mappedDevice);
}
}
return result;
},