Added notification logic and view api

This commit is contained in:
llsajjad
2025-09-22 16:05:08 +03:30
parent 2e2718a92e
commit cfc61daf71
23 changed files with 1944 additions and 152 deletions
@@ -0,0 +1,48 @@
// notification_service.dart
import 'dart:convert';
import 'package:tm_app/data/services/api/notification_api.dart';
import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart';
import 'package:tm_app/core/utils/result.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),
//NotificationApi.notifications,
method: 'GET',
(json) => NotificationResponseModel.fromJson(json),
);
return result;
}
Future<Result<NotificationResponseModel>> markAllAsRead() async {
final result = await _networkManager.makeRequest(
NotificationApi.markAllAsRead,
method: 'POST',
(json) => NotificationResponseModel.fromJson(json),
);
return result;
}
Future<Result<NotificationResponseModel>> markAsRead({
required String notificationId,
}) async {
final data = jsonEncode({'notification_id': notificationId});
final result = await _networkManager.makeRequest(
NotificationApi.markAsRead,
method: 'POST',
(json) => NotificationResponseModel.fromJson(json),
data: data,
);
return result;
}
}