mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-27 08:04:14 +00:00
Add functionality to fetch devices by room ID
Added a new method in DevicesCubit to fetch devices by room ID and updated related classes and API calls to support this functionality.
This commit is contained in:
@@ -1,30 +1,37 @@
|
||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
|
||||
class RoomModel {
|
||||
final int? id;
|
||||
final String? name;
|
||||
|
||||
final List<DevicesCategoryModel>? categories;
|
||||
List<DeviceModel>? devices;
|
||||
|
||||
RoomModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.categories,
|
||||
required this.devices,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'devices': categories,
|
||||
'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['roomId'],
|
||||
name: json['roomName'],
|
||||
categories: json['devices'],
|
||||
devices: devices,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user