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:
2026-07-06 21:15:39 +02:00
parent 38a271929c
commit 2be5051d12
13 changed files with 213 additions and 118 deletions
@@ -1,17 +0,0 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../mhsl_api.dart';
import 'get_breakers_response.dart';
class GetBreakers extends MhslApi<GetBreakersResponse> {
GetBreakers() : super('breaker/');
@override
GetBreakersResponse assemble(String raw) =>
GetBreakersResponse.fromJson(jsonDecode(raw) as Map<String, dynamic>);
@override
Future<Response>? request(Uri uri) => http.get(uri);
}
@@ -1,14 +0,0 @@
import '../../../request_cache.dart';
import 'get_breakers.dart';
import 'get_breakers_response.dart';
class GetBreakersCache extends SimpleCache<GetBreakersResponse> {
GetBreakersCache({super.onUpdate, super.renew})
: super(
cacheTime: RequestCache.cacheMinute,
loader: () => GetBreakers().run(),
fromJson: GetBreakersResponse.fromJson,
) {
start('breakers');
}
}
@@ -1,42 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../api_response.dart';
part 'get_breakers_response.g.dart';
@JsonSerializable(explicitToJson: true)
class GetBreakersResponse extends ApiResponse {
GetBreakersReponseObject global;
Map<String, GetBreakersReponseObject> regional;
GetBreakersResponse(this.global, this.regional);
factory GetBreakersResponse.fromJson(Map<String, dynamic> json) =>
_$GetBreakersResponseFromJson(json);
Map<String, dynamic> toJson() => _$GetBreakersResponseToJson(this);
}
@JsonSerializable()
class GetBreakersReponseObject {
List<BreakerArea> areas;
String message;
GetBreakersReponseObject(this.areas, this.message);
factory GetBreakersReponseObject.fromJson(Map<String, dynamic> json) =>
_$GetBreakersReponseObjectFromJson(json);
Map<String, dynamic> toJson() => _$GetBreakersReponseObjectToJson(this);
}
enum BreakerArea {
@JsonValue('GLOBAL')
global,
@JsonValue('TIMETABLE')
timetable,
@JsonValue('TALK')
talk,
@JsonValue('FILES')
files,
@JsonValue('MORE')
more,
}
@@ -1,55 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'get_breakers_response.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
GetBreakersResponse _$GetBreakersResponseFromJson(Map<String, dynamic> json) =>
GetBreakersResponse(
GetBreakersReponseObject.fromJson(
json['global'] as Map<String, dynamic>,
),
(json['regional'] as Map<String, dynamic>).map(
(k, e) => MapEntry(
k,
GetBreakersReponseObject.fromJson(e as Map<String, dynamic>),
),
),
)
..headers = (json['headers'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetBreakersResponseToJson(
GetBreakersResponse instance,
) => <String, dynamic>{
'headers': ?instance.headers,
'global': instance.global.toJson(),
'regional': instance.regional.map((k, e) => MapEntry(k, e.toJson())),
};
GetBreakersReponseObject _$GetBreakersReponseObjectFromJson(
Map<String, dynamic> json,
) => GetBreakersReponseObject(
(json['areas'] as List<dynamic>)
.map((e) => $enumDecode(_$BreakerAreaEnumMap, e))
.toList(),
json['message'] as String,
);
Map<String, dynamic> _$GetBreakersReponseObjectToJson(
GetBreakersReponseObject instance,
) => <String, dynamic>{
'areas': instance.areas.map((e) => _$BreakerAreaEnumMap[e]!).toList(),
'message': instance.message,
};
const _$BreakerAreaEnumMap = {
BreakerArea.global: 'GLOBAL',
BreakerArea.timetable: 'TIMETABLE',
BreakerArea.talk: 'TALK',
BreakerArea.files: 'FILES',
BreakerArea.more: 'MORE',
};