2026-06-06 16:07:05 -04:00
|
|
|
import 'device_event_type.dart';
|
|
|
|
|
|
2026-05-28 10:05:49 -04:00
|
|
|
class DeviceEvent {
|
|
|
|
|
final int id;
|
|
|
|
|
final String macAddress;
|
|
|
|
|
final DateTime createdOn;
|
2026-06-06 16:07:05 -04:00
|
|
|
final DeviceEventType eventType;
|
2026-05-28 10:05:49 -04:00
|
|
|
final String ipv4Address;
|
|
|
|
|
final String vendor;
|
2026-06-01 08:19:49 -04:00
|
|
|
final String scanner;
|
2026-05-28 10:05:49 -04:00
|
|
|
|
|
|
|
|
const DeviceEvent({
|
|
|
|
|
required this.id,
|
|
|
|
|
required this.macAddress,
|
|
|
|
|
required this.createdOn,
|
|
|
|
|
required this.eventType,
|
|
|
|
|
required this.ipv4Address,
|
|
|
|
|
required this.vendor,
|
2026-06-01 08:19:49 -04:00
|
|
|
required this.scanner,
|
2026-05-28 10:05:49 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
factory DeviceEvent.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
return DeviceEvent(
|
|
|
|
|
id: json['id'] as int,
|
|
|
|
|
macAddress: json['mac_address'] as String,
|
|
|
|
|
createdOn: DateTime.parse(json['created_on'] as String),
|
2026-06-06 16:07:05 -04:00
|
|
|
eventType: DeviceEventType.fromString(json['event_type'] as String),
|
2026-05-28 10:05:49 -04:00
|
|
|
ipv4Address: json['ipv4_address'] as String,
|
|
|
|
|
vendor: json['vendor'] as String,
|
2026-06-01 08:19:49 -04:00
|
|
|
scanner: json['scanner'] as String,
|
2026-05-28 10:05:49 -04:00
|
|
|
);
|
|
|
|
|
}
|
2026-06-01 08:19:49 -04:00
|
|
|
|
|
|
|
|
String get scannerLabel => switch (scanner) {
|
|
|
|
|
'Arp' => 'ARP',
|
|
|
|
|
'Mdns' => 'mDNS',
|
2026-06-01 18:13:33 -04:00
|
|
|
'Ssdp' => 'SSDP/UPnP',
|
2026-06-01 18:45:38 -04:00
|
|
|
'Dhcp' => 'DHCP',
|
2026-06-02 08:03:20 -04:00
|
|
|
'Snmp' => 'SNMP',
|
2026-06-01 08:19:49 -04:00
|
|
|
_ => scanner,
|
|
|
|
|
};
|
2026-05-28 10:05:49 -04:00
|
|
|
}
|