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:
@@ -17,7 +17,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
||||
@override
|
||||
Future<List<Hub>> getHubs() async {
|
||||
final ApiResponse response =
|
||||
await _apiService.get(ClientEndpoints.hubs.path);
|
||||
await _apiService.get(ClientEndpoints.hubs);
|
||||
final List<dynamic> items =
|
||||
(response.data as Map<String, dynamic>)['items'] as List<dynamic>;
|
||||
return items
|
||||
@@ -28,7 +28,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
||||
@override
|
||||
Future<List<CostCenter>> getCostCenters() async {
|
||||
final ApiResponse response =
|
||||
await _apiService.get(ClientEndpoints.costCenters.path);
|
||||
await _apiService.get(ClientEndpoints.costCenters);
|
||||
final List<dynamic> items =
|
||||
(response.data as Map<String, dynamic>)['items'] as List<dynamic>;
|
||||
return items
|
||||
@@ -52,7 +52,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
||||
String? costCenterId,
|
||||
}) async {
|
||||
final ApiResponse response = await _apiService.post(
|
||||
ClientEndpoints.hubCreate.path,
|
||||
ClientEndpoints.hubCreate,
|
||||
data: <String, dynamic>{
|
||||
'name': name,
|
||||
'fullAddress': fullAddress,
|
||||
@@ -88,7 +88,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
||||
String? costCenterId,
|
||||
}) async {
|
||||
final ApiResponse response = await _apiService.put(
|
||||
ClientEndpoints.hubUpdate(hubId).path,
|
||||
ClientEndpoints.hubUpdate(hubId),
|
||||
data: <String, dynamic>{
|
||||
'hubId': hubId,
|
||||
if (name != null) 'name': name,
|
||||
@@ -111,7 +111,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
||||
|
||||
@override
|
||||
Future<void> deleteHub(String hubId) async {
|
||||
await _apiService.delete(ClientEndpoints.hubDelete(hubId).path);
|
||||
await _apiService.delete(ClientEndpoints.hubDelete(hubId));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -120,7 +120,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
||||
required String nfcTagId,
|
||||
}) async {
|
||||
await _apiService.post(
|
||||
ClientEndpoints.hubAssignNfc(hubId).path,
|
||||
ClientEndpoints.hubAssignNfc(hubId),
|
||||
data: <String, dynamic>{'nfcTagId': nfcTagId},
|
||||
);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
||||
@override
|
||||
Future<List<HubManager>> getManagers(String hubId) async {
|
||||
final ApiResponse response =
|
||||
await _apiService.get(ClientEndpoints.hubManagers(hubId).path);
|
||||
await _apiService.get(ClientEndpoints.hubManagers(hubId));
|
||||
final List<dynamic> items =
|
||||
(response.data as Map<String, dynamic>)['items'] as List<dynamic>;
|
||||
return items
|
||||
@@ -143,7 +143,7 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
||||
required List<String> businessMembershipIds,
|
||||
}) async {
|
||||
await _apiService.post(
|
||||
ClientEndpoints.hubAssignManagers(hubId).path,
|
||||
ClientEndpoints.hubAssignManagers(hubId),
|
||||
data: <String, dynamic>{
|
||||
'businessMembershipIds': businessMembershipIds,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user