Merge pull request #94 from SyncrowIOT/SP-1471-BE-On-mobile-app-Error-while-retrieving-scene-details-on-4-6-Scenes-devices

Refactor device_info_model.dart and devices_api.dart
This commit is contained in:
mohammadnemer1
2025-04-28 16:13:34 +03:00
committed by GitHub
2 changed files with 11 additions and 9 deletions

View File

@ -77,7 +77,7 @@ class DeviceInfoModel {
uuid: json['uuid'],
productUuid: json['productUuid'],
productType: json['productType'],
permissionType: json['permissionType'],
permissionType: json['permissionType'] ?? '',
macAddress: json['macAddress'],
subspace: Subspace.fromJson(json['subspace']),
);

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;
}
@ -189,7 +190,7 @@ class DevicesAPI {
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
showServerMessage: false,
expectedResponseModel: (json) {
return json['data'];
return json['data'] as Map<String, dynamic>;
});
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;
},