migrated the breaker system to MarianumConnect and refactored the API response to a rule-based model with support for version-specific blocks using maxBuild.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../errors/marianumconnect_error.dart';
|
||||
import '../../marianumconnect_api.dart';
|
||||
import '../../marianumconnect_endpoint.dart';
|
||||
import 'get_breakers_response.dart';
|
||||
|
||||
/// Fetches the app maintenance breaker rules from `GET /api/mobile/v1/breaker`.
|
||||
/// The endpoint is public: the bearer token is attached if present but not
|
||||
/// required, so this also works before login (e.g. to block the whole app).
|
||||
class GetBreakers {
|
||||
final Dio _dio;
|
||||
|
||||
GetBreakers({Dio? dio}) : _dio = dio ?? MarianumConnectApi.dio();
|
||||
|
||||
Future<GetBreakersResponse> run() async {
|
||||
try {
|
||||
final response = await _dio.get<Map<String, dynamic>>(
|
||||
MarianumConnectEndpoint.resolve('breaker'),
|
||||
);
|
||||
return GetBreakersResponse.fromJson(response.data!);
|
||||
} on DioException catch (e) {
|
||||
throw mapMarianumConnectError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user