mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
add subspace and space information
This commit is contained in:
@ -0,0 +1,47 @@
|
||||
class DeviceSubspace {
|
||||
final String uuid;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
final String subspaceName;
|
||||
final bool disabled;
|
||||
|
||||
DeviceSubspace({
|
||||
required this.uuid,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
required this.subspaceName,
|
||||
required this.disabled,
|
||||
});
|
||||
|
||||
factory DeviceSubspace.fromJson(Map<String, dynamic> json) {
|
||||
return DeviceSubspace(
|
||||
uuid: json['uuid'] as String,
|
||||
createdAt: json['createdAt'] != null
|
||||
? DateTime.tryParse(json['createdAt'].toString())
|
||||
: null,
|
||||
updatedAt: json['updatedAt'] != null
|
||||
? DateTime.tryParse(json['updatedAt'].toString())
|
||||
: null,
|
||||
subspaceName: json['subspaceName'] as String,
|
||||
disabled: json['disabled'] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'uuid': uuid,
|
||||
'createdAt': createdAt?.toIso8601String(),
|
||||
'updatedAt': updatedAt?.toIso8601String(),
|
||||
'subspaceName': subspaceName,
|
||||
'disabled': disabled,
|
||||
};
|
||||
}
|
||||
|
||||
static List<DeviceSubspace> listFromJson(List<dynamic> jsonList) {
|
||||
return jsonList.map((json) => DeviceSubspace.fromJson(json)).toList();
|
||||
}
|
||||
|
||||
static List<Map<String, dynamic>> listToJson(List<DeviceSubspace> subspaces) {
|
||||
return subspaces.map((subspace) => subspace.toJson()).toList();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user