enum InboxMessageType { friendRequest, calendar, system, group } enum InboxMessageStatus { pending, accepted, rejected, dismissed } class InboxMessage { final String id; final String recipientId; final String? senderId; final InboxMessageType messageType; final String? scheduleItemId; final String? friendshipId; final Map? content; final bool isRead; final InboxMessageStatus status; final DateTime createdAt; const InboxMessage({ required this.id, required this.recipientId, required this.senderId, required this.messageType, required this.scheduleItemId, required this.friendshipId, required this.content, required this.isRead, required this.status, required this.createdAt, }); factory InboxMessage.fromJson(Map json) { return InboxMessage( id: json['id'] as String, recipientId: json['recipient_id'] as String, senderId: json['sender_id'] as String?, messageType: _messageTypeFromApi(json['message_type'] as String), scheduleItemId: json['schedule_item_id'] as String?, friendshipId: json['friendship_id'] as String?, content: json['content'] as Map?, isRead: json['is_read'] as bool, status: _messageStatusFromApi(json['status'] as String), createdAt: DateTime.parse(json['created_at'] as String), ); } } InboxMessageType _messageTypeFromApi(String raw) { switch (raw) { case 'friend_request': return InboxMessageType.friendRequest; case 'calendar': return InboxMessageType.calendar; case 'system': return InboxMessageType.system; case 'group': return InboxMessageType.group; default: throw StateError('Unsupported inbox message type: $raw'); } } InboxMessageStatus _messageStatusFromApi(String raw) { switch (raw) { case 'pending': return InboxMessageStatus.pending; case 'accepted': return InboxMessageStatus.accepted; case 'rejected': return InboxMessageStatus.rejected; case 'dismissed': return InboxMessageStatus.dismissed; default: throw StateError('Unsupported inbox message status: $raw'); } }