Added api for custom timetable events

This commit is contained in:
2024-02-12 01:00:12 +01:00
parent 3eae5ba10a
commit 22db412e75
36 changed files with 849 additions and 229 deletions

View File

@ -1,6 +1,9 @@
import 'package:intl/intl.dart';
import '../../api/apiResponse.dart';
import '../../api/mhsl/customTimetableEvent/get/getCustomTimetableEventCache.dart';
import '../../api/mhsl/customTimetableEvent/get/getCustomTimetableEventParams.dart';
import '../../api/mhsl/customTimetableEvent/get/getCustomTimetableEventResponse.dart';
import '../../api/webuntis/queries/getHolidays/getHolidaysCache.dart';
import '../../api/webuntis/queries/getHolidays/getHolidaysResponse.dart';
import '../../api/webuntis/queries/getRooms/getRoomsCache.dart';
@ -10,6 +13,7 @@ import '../../api/webuntis/queries/getSubjects/getSubjectsResponse.dart';
import '../../api/webuntis/queries/getTimetable/getTimetableCache.dart';
import '../../api/webuntis/queries/getTimetable/getTimetableResponse.dart';
import '../../api/webuntis/webuntisError.dart';
import '../accountData.dart';
import '../dataHolder.dart';
class TimetableProps extends DataHolder {
@ -30,17 +34,20 @@ class TimetableProps extends DataHolder {
GetHolidaysResponse? _getHolidaysResponse;
GetHolidaysResponse get getHolidaysResponse => _getHolidaysResponse!;
GetCustomTimetableEventResponse? _getCustomTimetableEventResponse;
GetCustomTimetableEventResponse get getCustomTimetableEventResponse => _getCustomTimetableEventResponse!;
WebuntisError? error;
WebuntisError? get getError => error;
bool get hasError => error != null;
@override
List<ApiResponse?> properties() {
return [_getTimetableResponse, _getRoomsResponse, _getSubjectsResponse, _getHolidaysResponse];
return [_getTimetableResponse, _getRoomsResponse, _getSubjectsResponse, _getHolidaysResponse, _getCustomTimetableEventResponse];
}
@override
void run() {
void run({renew}) {
GetTimetableCache(
startdate: int.parse(DateFormat("yyyyMMdd").format(startDate)),
enddate: int.parse(DateFormat("yyyyMMdd").format(endDate)),
@ -78,6 +85,17 @@ class TimetableProps extends DataHolder {
// {"jsonrpc":"2.0","id":"ID","result":[]}
// """));
GetCustomTimetableEventCache(
renew: renew,
GetCustomTimetableEventParams(
AccountData().getUserSecret()
),
onUpdate: (GetCustomTimetableEventResponse data) => {
_getCustomTimetableEventResponse = data,
notifyListeners(),
}
);
notifyListeners();
}