feat: Update API endpoint usage in repositories to remove redundant path property

- Refactored multiple repository implementations across client and staff features to directly use endpoint objects without accessing the `path` property.
- Introduced a new `FeatureGate` class for client-side feature gating based on user scopes, allowing for better access control to API endpoints.
- Added `ApiEndpoint` class to represent API endpoints with their paths and required scopes for future feature gating.
This commit is contained in:
Achintha Isuru
2026-03-17 12:01:06 -04:00
parent 57bba8ab4e
commit 376b4e4431
47 changed files with 240 additions and 139 deletions

View File

@@ -14,7 +14,7 @@ class ProfileRepositoryImpl {
/// Fetches the staff profile from the V2 session endpoint.
Future<Staff> getStaffProfile() async {
final ApiResponse response =
await _api.get(StaffEndpoints.session.path);
await _api.get(StaffEndpoints.session);
final Map<String, dynamic> json =
response.data['staff'] as Map<String, dynamic>;
return Staff.fromJson(json);
@@ -23,7 +23,7 @@ class ProfileRepositoryImpl {
/// Fetches the profile section completion statuses.
Future<ProfileSectionStatus> getProfileSections() async {
final ApiResponse response =
await _api.get(StaffEndpoints.profileSections.path);
await _api.get(StaffEndpoints.profileSections);
final Map<String, dynamic> json =
response.data as Map<String, dynamic>;
return ProfileSectionStatus.fromJson(json);
@@ -31,6 +31,6 @@ class ProfileRepositoryImpl {
/// Signs out the current user.
Future<void> signOut() async {
await _api.post(AuthEndpoints.signOut.path);
await _api.post(AuthEndpoints.signOut);
}
}