mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
33 lines
811 B
Dart
33 lines
811 B
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
class Occupacy extends Equatable {
|
|
final DateTime date;
|
|
final String occupancy;
|
|
final String spaceUuid;
|
|
final int occupiedSeconds;
|
|
|
|
const Occupacy({
|
|
required this.date,
|
|
required this.occupancy,
|
|
required this.spaceUuid,
|
|
required this.occupiedSeconds,
|
|
});
|
|
|
|
factory Occupacy.fromJson(Map<String, dynamic> json) {
|
|
return Occupacy(
|
|
date: DateTime.parse(json['event_date'] as String? ?? '${DateTime.now()}'),
|
|
occupancy: (json['occupancy_percentage'] ?? 0).toString(),
|
|
spaceUuid: json['space_uuid'] as String? ?? '',
|
|
occupiedSeconds: json['occupied_seconds'] as int? ?? 0,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
date,
|
|
occupancy,
|
|
spaceUuid,
|
|
occupiedSeconds,
|
|
];
|
|
}
|