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:
@@ -20,7 +20,7 @@ class CoverageRepositoryImpl implements CoverageRepository {
|
||||
final String dateStr =
|
||||
'${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
|
||||
final ApiResponse response = await _apiService.get(
|
||||
ClientEndpoints.coverage.path,
|
||||
ClientEndpoints.coverage,
|
||||
params: <String, dynamic>{'date': dateStr},
|
||||
);
|
||||
final List<dynamic> items = response.data['items'] as List<dynamic>;
|
||||
@@ -35,7 +35,7 @@ class CoverageRepositoryImpl implements CoverageRepository {
|
||||
final String dateStr =
|
||||
'${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
|
||||
final ApiResponse response = await _apiService.get(
|
||||
ClientEndpoints.coverageStats.path,
|
||||
ClientEndpoints.coverageStats,
|
||||
params: <String, dynamic>{'date': dateStr},
|
||||
);
|
||||
return CoverageStats.fromJson(response.data as Map<String, dynamic>);
|
||||
@@ -67,7 +67,7 @@ class CoverageRepositoryImpl implements CoverageRepository {
|
||||
body['markAsFavorite'] = markAsFavorite;
|
||||
}
|
||||
await _apiService.post(
|
||||
ClientEndpoints.coverageReviews.path,
|
||||
ClientEndpoints.coverageReviews,
|
||||
data: body,
|
||||
);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class CoverageRepositoryImpl implements CoverageRepository {
|
||||
body['reason'] = reason;
|
||||
}
|
||||
await _apiService.post(
|
||||
ClientEndpoints.coverageCancelLateWorker(assignmentId).path,
|
||||
ClientEndpoints.coverageCancelLateWorker(assignmentId),
|
||||
data: body,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user