73 lines
1.4 KiB
Dart
73 lines
1.4 KiB
Dart
enum BoxRole { administrator, guest }
|
|
|
|
enum CredentialKind { permanent, oneTime }
|
|
|
|
class SavedBox {
|
|
const SavedBox({
|
|
required this.remoteId,
|
|
required this.name,
|
|
required this.identityKey,
|
|
required this.role,
|
|
});
|
|
|
|
final String remoteId;
|
|
final String name;
|
|
final String identityKey;
|
|
final BoxRole role;
|
|
|
|
Map<String, Object?> toJson() => <String, Object?>{
|
|
'remote_id': remoteId,
|
|
'name': name,
|
|
'identity_key': identityKey,
|
|
'role': role.name,
|
|
};
|
|
|
|
factory SavedBox.fromJson(Map<String, Object?> json) => SavedBox(
|
|
remoteId: json['remote_id']! as String,
|
|
name: json['name']! as String,
|
|
identityKey: json['identity_key']! as String,
|
|
role: json['role'] == BoxRole.guest.name
|
|
? BoxRole.guest
|
|
: BoxRole.administrator,
|
|
);
|
|
}
|
|
|
|
class AccessCode {
|
|
const AccessCode({
|
|
required this.id,
|
|
required this.code,
|
|
required this.kind,
|
|
});
|
|
|
|
final String id;
|
|
final String code;
|
|
final CredentialKind kind;
|
|
}
|
|
|
|
class NfcTag {
|
|
const NfcTag({required this.id, required this.uid, required this.name});
|
|
|
|
final String id;
|
|
final String uid;
|
|
final String name;
|
|
}
|
|
|
|
class OpeningEvent {
|
|
const OpeningEvent({
|
|
required this.date,
|
|
required this.kind,
|
|
required this.actor,
|
|
});
|
|
|
|
final DateTime date;
|
|
final int kind;
|
|
final String actor;
|
|
}
|
|
|
|
class GuestIdentity {
|
|
const GuestIdentity({required this.name, required this.key});
|
|
|
|
final String name;
|
|
final String key;
|
|
}
|