Skip to content

Commit a793bac

Browse files
committed
feat: implement file management feature with repository and provider, and add notification log status update to notifications repository
1 parent 92f03b9 commit a793bac

4 files changed

Lines changed: 106 additions & 17 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'dart:io';
2+
import 'package:mobile/core/network/api/export.dart';
3+
4+
/// {@template files_repository}
5+
/// Data layer for file operations.
6+
/// {@endtemplate}
7+
class FilesRepository {
8+
/// {@macro files_repository}
9+
FilesRepository({required FilesService service}) : _service = service;
10+
11+
final FilesService _service;
12+
13+
Future<FileUploadResponse> uploadFile(File file) =>
14+
_service.uploadFileApiV1FilesUploadPost(file: file);
15+
16+
Future<void> getFile(String key) =>
17+
_service.getFileApiV1FilesKeyGet(key: key);
18+
19+
Future<void> deleteFile(String key) =>
20+
_service.deleteFileApiV1FilesKeyDelete(key: key);
21+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'package:mobile/core/network/api/export.dart';
2+
import 'package:mobile/features/auth/presentation/providers/auth_provider.dart';
3+
import 'package:mobile/features/files/data/files_repository.dart';
4+
import 'package:riverpod_annotation/riverpod_annotation.dart';
5+
6+
part 'files_provider.g.dart';
7+
8+
@riverpod
9+
FilesRepository filesRepository(Ref ref) {
10+
final apiClient = ref.watch(apiClientWrapperProvider);
11+
return FilesRepository(service: FilesService(apiClient.dio));
12+
}

apps/mobile/lib/features/files/presentation/providers/files_provider.g.dart

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/mobile/lib/features/notifications/data/notifications_repository.dart

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class NotificationsRepository {
88
NotificationsRepository({
99
required NotificationsService notificationsService,
1010
required NotificationLogsService notificationLogsService,
11-
}) : _notificationsService = notificationsService,
12-
_notificationLogsService = notificationLogsService;
11+
}) : _notificationsService = notificationsService,
12+
_notificationLogsService = notificationLogsService;
1313

1414
final NotificationsService _notificationsService;
1515
final NotificationLogsService _notificationLogsService;
@@ -20,27 +20,23 @@ class NotificationsRepository {
2020
Future<DeviceTokenResponse> registerDeviceToken({
2121
required String token,
2222
required DeviceTokenCreatePlatform platform,
23-
}) =>
24-
_notificationsService
25-
.registerDeviceTokenApiV1NotificationsDeviceTokensPost(
23+
}) => _notificationsService
24+
.registerDeviceTokenApiV1NotificationsDeviceTokensPost(
2625
body: DeviceTokenCreate(token: token, platform: platform),
2726
);
2827

29-
Future<void> unregisterDeviceToken(String tokenId) =>
30-
_notificationsService
31-
.unregisterDeviceTokenApiV1NotificationsDeviceTokensTokenIdDelete(
28+
Future<void> unregisterDeviceToken(String tokenId) => _notificationsService
29+
.unregisterDeviceTokenApiV1NotificationsDeviceTokensTokenIdDelete(
3230
tokenId: tokenId,
3331
);
3432

3533
Future<PaginatedResponseNotificationLogResponse> listLogs({
3634
int page = 1,
3735
int limit = 20,
38-
}) =>
39-
_notificationLogsService
40-
.listNotificationLogsApiV1NotificationLogsGet(
41-
page: page,
42-
limit: limit,
43-
);
36+
}) => _notificationLogsService.listNotificationLogsApiV1NotificationLogsGet(
37+
page: page,
38+
limit: limit,
39+
);
4440

4541
Future<NotificationPreferenceResponse> getPreferences() =>
4642
_notificationLogsService
@@ -50,13 +46,21 @@ class NotificationsRepository {
5046
bool? wellnessAlerts,
5147
bool? medicationReminders,
5248
bool? systemUpdates,
53-
}) =>
54-
_notificationLogsService
55-
.updatePreferencesApiV1NotificationLogsPreferencesPut(
49+
}) => _notificationLogsService
50+
.updatePreferencesApiV1NotificationLogsPreferencesPut(
5651
body: NotificationPreferenceUpdate(
5752
wellnessAlerts: wellnessAlerts,
5853
medicationReminders: medicationReminders,
5954
systemUpdates: systemUpdates,
6055
),
6156
);
57+
58+
Future<NotificationLogResponse> updateLogStatus({
59+
required String logId,
60+
required String status,
61+
}) => _notificationLogsService
62+
.updateLogStatusApiV1NotificationLogsLogIdStatusPatch(
63+
logId: logId,
64+
body: NotificationLogStatusUpdate(status: status),
65+
);
6266
}

0 commit comments

Comments
 (0)