import '../core/api_client.dart'; class InAppNotification { final String id; final String type; final String title; final String message; const InAppNotification({ required this.id, required this.type, required this.title, required this.message, }); factory InAppNotification.fromJson(Map json) => InAppNotification( id: json['id']?.toString() ?? '', type: json['type']?.toString() ?? '', title: json['title']?.toString() ?? '健康提醒', message: json['message']?.toString() ?? '', ); } class InAppNotificationService { final ApiClient _api; const InAppNotificationService(this._api); Future> getPending() async { final response = await _api.get('/api/notifications/pending'); final items = response.data['data'] as List? ?? const []; return items .whereType() .map((item) => InAppNotification.fromJson(Map.from(item))) .where((item) => item.id.isNotEmpty) .toList(); } Future acknowledge(String id) async { await _api.post('/api/notifications/$id/acknowledge'); } }