Files
tm_app/lib/data/services/notification_service.dart
T
2025-09-28 14:28:18 +03:30

69 lines
2.1 KiB
Dart

// notification_service.dart
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 {
NotificationsService({required NetworkManager networkManager})
: _networkManager = networkManager;
final NetworkManager _networkManager;
Future<Result<NotificationResponseModel>> getNotifications({
required int limit,
required int offset,
}) async {
final result = await _networkManager.makeRequest(
NotificationApi.getNotifications(limit: limit, offset: offset),
method: 'GET',
(json) => NotificationResponseModel.fromJson(json),
);
return result;
}
Future<Result<Map<String, dynamic>>> markAllAsRead() async {
final result = await _networkManager.makeRequest(
NotificationApi.markAllAsRead,
method: 'GET',
(json) => json,
);
return result;
}
Future<Result<NotificationResponseModel>> markAsRead({
required String notificationId,
}) async {
final result = await _networkManager.makeRequest(
'${NotificationApi.markAsRead}/$notificationId',
method: 'GET',
(json) => NotificationResponseModel.fromJson(json),
);
return result;
}
Future<Result<NotificationResponseModel>> getUnreadNotifications({
required int limit,
required int offset,
}) async {
final result = await _networkManager.makeRequest(
NotificationApi.getUnreadNotifications(limit: limit, offset: offset),
method: 'GET',
(json) => NotificationResponseModel.fromJson(json),
);
return result;
}
Future<Result<NotificationResponseModel>> getImportantNotifications({
required int limit,
required int offset,
}) async {
final result = await _networkManager.makeRequest(
NotificationApi.getImportantNotifications(limit: limit, offset: offset),
method: 'GET',
(json) => NotificationResponseModel.fromJson(json),
);
return result;
}
}