Files
Eventify-frontend/lib/features/notifications/services/notification_service.dart
Sicherhaven 8955febd00 feat: Phase 1 critical gaps — gamification API, Razorpay checkout, Google OAuth, notifications
- Fix gamification endpoints to use Node.js server (app.eventifyplus.com)
- Replace 6 mock gamification methods with real API calls (dashboard, leaderboard, shop, redeem, submit)
- Add booking models, service, payment service (Razorpay), checkout provider
- Add 3-step CheckoutScreen with Razorpay native modal integration
- Add Google OAuth login (Flutter + Django backend)
- Add full notifications system (Django model + 3 endpoints + Flutter UI)
- Register CheckoutProvider, NotificationProvider in main.dart MultiProvider
- Wire notification bell in HomeScreen app bar
- Add razorpay_flutter ^1.3.7 and google_sign_in ^6.2.2 packages
2026-04-04 15:46:53 +05:30

42 lines
1.4 KiB
Dart

// lib/features/notifications/services/notification_service.dart
import '../../../core/api/api_client.dart';
import '../../../core/api/api_endpoints.dart';
import '../models/notification_model.dart';
class NotificationService {
final ApiClient _api = ApiClient();
/// Fetch notifications for current user (paginated).
Future<List<NotificationModel>> getNotifications({int page = 1, int pageSize = 20}) async {
final res = await _api.post(
ApiEndpoints.notificationList,
body: {'page': page, 'page_size': pageSize},
);
final rawList = res['notifications'] ?? res['data'] ?? [];
if (rawList is List) {
return rawList
.map((e) => NotificationModel.fromJson(Map<String, dynamic>.from(e as Map)))
.toList();
}
return [];
}
/// Mark a single notification as read, or all if [notificationId] is null.
Future<void> markAsRead({int? notificationId}) async {
final body = <String, dynamic>{};
if (notificationId != null) {
body['notification_id'] = notificationId;
} else {
body['mark_all'] = true;
}
await _api.post(ApiEndpoints.notificationMarkRead, body: body);
}
/// Get unread notification count (lightweight).
Future<int> getUnreadCount() async {
final res = await _api.post(ApiEndpoints.notificationCount);
return (res['unread_count'] as num?)?.toInt() ?? 0;
}
}