From d65b4599363e8efd67cdeb46a4908aec8b271568 Mon Sep 17 00:00:00 2001 From: Luna <82129596+hairy-tortoise@users.noreply.github.com> Date: Tue, 12 Sep 2023 21:56:30 +0200 Subject: [PATCH] Updated readme and fixed error (#4) * Corrected mistakes * Fixed error where _parseTimeGrid always returned null --- README.md | 8 ++++---- lib/untis.dart | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 03bb015..06402cc 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,16 @@ The basic tool used to interact with the API is the Session object. // .init(server, school, username, password, Optional: useragent) Session mySession = await Session.init("demo.server.com", "demo_school", "demo_user", "demo_pass") // The ID of the account which credentials you used should now be available over the .userId attribute -var myId = session.userId; +var myId = mySession.userId!; // Alternatively you can also search for a student var myId = (await mySession.searchStudent("demo_forename", "demo_surname"))!.surnameMatches![0].id; ``` Basic methods act just as you expect them to. ```dart // To get cancellations for a specific day, simply call the .getCancellations method with a startDate -List cancellationsTmwr = await mySession.getCancellations(mySession.userId, startDate: DateTime.now().add(Duration(days: 1))); +List cancellationsTmwr = await mySession.getCancellations(mySession.userId!, startDate: DateTime.now().add(Duration(days: 1))); // The same principle applies to the .getTimetable method, startDate and endDate (inclusive) are optional and will default to the current day -List timetable = await mySession.getTimetable(mySession.userId); +List timetable = await mySession.getTimetable(mySession.userId!); ``` Some methods like getStudent will cache their result for 30minutes by default. ```dart @@ -41,7 +41,7 @@ mySession.cacheDisposeTime = 60; // Cached values will now stay available for 60 You want to program a timetable app? These methods might be useful. ```dart // Get a timegrid that specifies the period time spans for each day -Timegrid myTimegrid = await mySession.getTimegrid(); +TimeGrid myTimeGrid = await mySession.getTimeGrid(); // Get the timetable of the current week DateTime mostRecentWeekday(DateTime date, int weekday) => DateTime(date.year, date.month, date.day - (date.weekday - weekday) % 7); DateTime monday = mostRecentWeekday(DateTime.now(), DateTime.monday), friday = mostRecentWeekday(DateTime.now(), DateTime.friday); diff --git a/lib/untis.dart b/lib/untis.dart index a569c6a..bcb11c1 100644 --- a/lib/untis.dart +++ b/lib/untis.dart @@ -185,7 +185,7 @@ class Session { var dayDict = rawTimeGrid.firstWhere((element) => (element["day"] == day)); List dayData = dayDict["timeUnits"]; - List.generate( + return List.generate( dayData.length, (timePeriod) => List.generate(2, (periodBorder) { String border = List.from(["startTime", "endTime"])[periodBorder]; @@ -196,7 +196,6 @@ class Session { } else { return null; } - return null; })); }