import 'package:pshared/models/describable.dart'; import 'package:pshared/models/permissions/bound/describable.dart'; import 'package:pshared/models/permissions/bound.dart'; import 'package:pshared/models/recipient/status.dart'; import 'package:pshared/models/recipient/type.dart'; import 'package:pshared/models/storable.dart'; class RecipientModel implements PermissionBoundStorableDescribable { final Storable storable; final PermissionBound permissionBound; final Describable describable; final String email; final String? avatarUrl; final RecipientStatus status; final RecipientType type; final bool isArchived; const RecipientModel({ required this.storable, required this.permissionBound, required this.describable, required this.email, required this.status, required this.type, this.avatarUrl, this.isArchived = false, }); @override String get id => storable.id; @override DateTime get createdAt => storable.createdAt; @override DateTime get updatedAt => storable.updatedAt; @override String get organizationRef => permissionBound.organizationRef; @override String get permissionRef => permissionBound.permissionRef; @override String get name => describable.name; @override String? get description => describable.description; RecipientModel copyWith({ Describable? describable, String? email, String? Function()? avatarUrl, RecipientStatus? status, RecipientType? type, bool? isArchived, }) => RecipientModel( storable: storable, permissionBound: permissionBound, describable: describableCopyWithOther(this.describable, describable), email: email ?? this.email, avatarUrl: avatarUrl != null ? avatarUrl() : this.avatarUrl, status: status ?? this.status, type: type ?? this.type, isArchived: isArchived ?? this.isArchived, ); }