Implement Webuntis HTTP Api and Display
This commit is contained in:
23
lib/api/webuntis/queries/getRooms/getRoomsCache.dart
Normal file
23
lib/api/webuntis/queries/getRooms/getRoomsCache.dart
Normal file
@ -0,0 +1,23 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:marianum_mobile/api/requestCache.dart';
|
||||
import 'package:marianum_mobile/api/webuntis/queries/getRooms/getRoomsResponse.dart';
|
||||
|
||||
import 'getRooms.dart';
|
||||
|
||||
class GetRoomsCache extends RequestCache<GetRoomsResponse> {
|
||||
GetRoomsCache({onUpdate}) : super(60 * 60, onUpdate) {
|
||||
start("rooms", "data");
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetRoomsResponse> onLoad() {
|
||||
return GetRooms().run();
|
||||
}
|
||||
|
||||
@override
|
||||
GetRoomsResponse onLocalData(String json) {
|
||||
return GetRoomsResponse.fromJson(jsonDecode(json));
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,7 @@ import 'package:marianum_mobile/api/webuntis/apiResponse.dart';
|
||||
|
||||
part 'getRoomsResponse.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class GetRoomsResponse extends ApiResponse {
|
||||
Set<GetRoomsResponseObject> result;
|
||||
|
||||
|
@ -16,7 +16,7 @@ GetRoomsResponse _$GetRoomsResponseFromJson(Map<String, dynamic> json) =>
|
||||
|
||||
Map<String, dynamic> _$GetRoomsResponseToJson(GetRoomsResponse instance) =>
|
||||
<String, dynamic>{
|
||||
'result': instance.result.toList(),
|
||||
'result': instance.result.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
GetRoomsResponseObject _$GetRoomsResponseObjectFromJson(
|
||||
|
Reference in New Issue
Block a user