mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 01:35:23 +00:00
Refactor device_info_model.dart and devices_api.dart
This commit is contained in:
@ -77,7 +77,7 @@ class DeviceInfoModel {
|
|||||||
uuid: json['uuid'],
|
uuid: json['uuid'],
|
||||||
productUuid: json['productUuid'],
|
productUuid: json['productUuid'],
|
||||||
productType: json['productType'],
|
productType: json['productType'],
|
||||||
permissionType: json['permissionType'],
|
permissionType: json['permissionType'] ?? '',
|
||||||
macAddress: json['macAddress'],
|
macAddress: json['macAddress'],
|
||||||
subspace: Subspace.fromJson(json['subspace']),
|
subspace: Subspace.fromJson(json['subspace']),
|
||||||
);
|
);
|
||||||
|
@ -102,7 +102,8 @@ class DevicesAPI {
|
|||||||
static Future<Map<String, dynamic>> getPowerClampStatus(
|
static Future<Map<String, dynamic>> getPowerClampStatus(
|
||||||
String deviceId) async {
|
String deviceId) async {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceFunctionsStatus
|
||||||
|
.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
@ -144,7 +145,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceScene.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceScene.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -593,10 +594,11 @@ class DevicesAPI {
|
|||||||
}
|
}
|
||||||
final result = <DeviceModel>[];
|
final result = <DeviceModel>[];
|
||||||
for (final device in data) {
|
for (final device in data) {
|
||||||
final mappedDevice = DeviceModel.fromJson(device);
|
final mappedDevice = DeviceModel.fromJson(device);
|
||||||
if (mappedDevice.productType?.name != DeviceType.FlushMountedSensor.name) {
|
if (mappedDevice.productType?.name !=
|
||||||
result.add(mappedDevice);
|
DeviceType.FlushMountedSensor.name) {
|
||||||
}
|
result.add(mappedDevice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user