games_app/prediqo_mobile/lib/data/models/notification_models.dart
2026-07-25 22:48:54 +02:00

54 lines
1.5 KiB
Dart

/// User security / inbox notifications.
library;
class SecurityNotificationModel {
const SecurityNotificationModel({
required this.id,
required this.eventType,
required this.title,
required this.body,
this.readAt,
required this.createdAt,
});
final String id;
final String eventType;
final String title;
final String body;
final String? readAt;
final String createdAt;
bool get isUnread => readAt == null || readAt!.isEmpty;
factory SecurityNotificationModel.fromJson(Map<String, dynamic> json) =>
SecurityNotificationModel(
id: (json['id'] ?? '').toString(),
eventType: (json['eventType'] ?? '').toString(),
title: (json['title'] ?? '').toString(),
body: (json['body'] ?? '').toString(),
readAt: json['readAt']?.toString(),
createdAt: (json['createdAt'] ?? '').toString(),
);
}
class SecurityNotificationsPage {
const SecurityNotificationsPage({
required this.items,
required this.total,
required this.unreadCount,
});
final List<SecurityNotificationModel> items;
final int total;
final int unreadCount;
factory SecurityNotificationsPage.fromJson(Map<String, dynamic> json) =>
SecurityNotificationsPage(
items: (json['items'] as List<dynamic>? ?? [])
.map((e) => SecurityNotificationModel.fromJson(e as Map<String, dynamic>))
.toList(),
total: (json['total'] as num?)?.toInt() ?? 0,
unreadCount: (json['unreadCount'] as num?)?.toInt() ?? 0,
);
}