mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
41 lines
898 B
Dart
41 lines
898 B
Dart
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|
|
|
class RoomModel {
|
|
final String? id;
|
|
final String? name;
|
|
final SpaceType type;
|
|
List<DeviceModel>? devices;
|
|
|
|
RoomModel({
|
|
required this.id,
|
|
required this.name,
|
|
required this.type,
|
|
required this.devices,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'type': type,
|
|
'devices': devices,
|
|
};
|
|
}
|
|
|
|
factory RoomModel.fromJson(Map<String, dynamic> json) {
|
|
List<DeviceModel> devices = [];
|
|
if (json['devices'] != null) {
|
|
for (var device in json['devices']) {
|
|
devices.add(DeviceModel.fromJson(device));
|
|
}
|
|
}
|
|
return RoomModel(
|
|
id: json['uuid'],
|
|
name: json['name'],
|
|
type: spaceTypesMap[json['type']]!,
|
|
devices: [],
|
|
);
|
|
}
|
|
}
|