Implement Webuntis HTTP Api and Display

This commit is contained in:
2023-02-15 20:33:05 +01:00
parent 7432972b3c
commit 2b6dc8e3e6
42 changed files with 746 additions and 287 deletions

View File

@ -15,7 +15,6 @@ class GetTimetable extends WebuntisApi {
@override
Future<GetTimetableResponse> run() async {
String rawAnswer = await query(this);
log(rawAnswer);
return finalize(GetTimetableResponse.fromJson(jsonDecode(rawAnswer)));
}

View File

@ -0,0 +1,40 @@
import 'dart:convert';
import 'dart:developer';
import 'package:localstore/localstore.dart';
import 'package:marianum_mobile/api/requestCache.dart';
import '../authenticate/authenticate.dart';
import 'getTimetable.dart';
import 'getTimetableParams.dart';
import 'getTimetableResponse.dart';
class GetTimetableCache extends RequestCache<GetTimetableResponse> {
int day;
GetTimetableCache({required onUpdate, required this.day}) : super(30, onUpdate) {
start("timetable", "$day");
}
@override
GetTimetableResponse onLocalData(String json) {
return GetTimetableResponse.fromJson(jsonDecode(json));
}
@override
Future<GetTimetableResponse> onLoad() async {
return GetTimetable(
GetTimetableParams(
options: GetTimetableParamsOptions(
element: GetTimetableParamsOptionsElement(
id: (await Authenticate.getSession()).personId,
type: 5,
keyType: GetTimetableParamsOptionsElementKeyType.id,
),
startDate: day,
endDate: day,
)
)
).run();
}
}