mark single notification as read
This commit is contained in:
@@ -39,4 +39,10 @@ class NotificationsRepository {
|
||||
offset: offset,
|
||||
);
|
||||
}
|
||||
|
||||
Future<Result<NotificationResponseModel>> markAsRead({
|
||||
required String notificationId,
|
||||
}) {
|
||||
return _notificationsService.markAsRead(notificationId: notificationId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,20 @@ class NotificationApi {
|
||||
}
|
||||
|
||||
static const String markAllAsRead = '/api/v1/notifications/mark';
|
||||
static const String markAsRead = '/api/v1/notifications/mark-as-read';
|
||||
static const String markAsRead = '/api/v1/notifications/mark';
|
||||
|
||||
static const String unreadNotifications = '/api/v1/notifications?seen=false';
|
||||
static String getUnreadNotifications({required int limit, required int offset}) {
|
||||
static String getUnreadNotifications({
|
||||
required int limit,
|
||||
required int offset,
|
||||
}) {
|
||||
return '/api/v1/notifications?seen=false&limit=$limit&offset=$offset';
|
||||
}
|
||||
|
||||
static String getImportantNotifications({required int limit, required int offset}) {
|
||||
static String getImportantNotifications({
|
||||
required int limit,
|
||||
required int offset,
|
||||
}) {
|
||||
return '/api/v1/notifications?priority=important&limit=$limit&offset=$offset';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// notification_service.dart
|
||||
import 'dart:convert';
|
||||
import 'package:tm_app/core/utils/result.dart';
|
||||
import 'package:tm_app/data/services/api/notification_api.dart';
|
||||
import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart';
|
||||
|
||||
import '../../core/network/network_manager.dart';
|
||||
|
||||
class NotificationsService {
|
||||
@@ -34,13 +34,11 @@ class NotificationsService {
|
||||
Future<Result<NotificationResponseModel>> markAsRead({
|
||||
required String notificationId,
|
||||
}) async {
|
||||
final data = jsonEncode({'notification_id': notificationId});
|
||||
final result = await _networkManager.makeRequest(
|
||||
NotificationApi.markAsRead,
|
||||
method: 'POST',
|
||||
'${NotificationApi.markAsRead}/$notificationId',
|
||||
method: 'GET',
|
||||
(json) => NotificationResponseModel.fromJson(json),
|
||||
data: data,
|
||||
);
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user