Implement Webuntis HTTP Api and Display
This commit is contained in:
@ -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)));
|
||||
}
|
||||
|
||||
|
40
lib/api/webuntis/queries/getTimetable/getTimetableCache.dart
Normal file
40
lib/api/webuntis/queries/getTimetable/getTimetableCache.dart
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user