Skip to content

Commit 376a55c

Browse files
committed
Add get own timetable method
1 parent a03f65e commit 376a55c

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

API.Test/TimeTableTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void GetTimetable()
8282
{
8383
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
8484

85-
Task<Period[]> timetable = Client.GetTimetableForStudentAsync(Client.User as Student, new DateTime(2023, 05, 29), new DateTime(2023, 09, 2));
85+
Task<Period[]> timetable = Client.GetOwnTimetableAsync(new DateTime(2023, 05, 29), new DateTime(2023, 09, 2));
8686
timetable.Wait();
8787
if (timetable.Result.Length > 0)
8888
Assert.Pass();

WebUntisAPI.Client/WebUntisClient.TimeTable.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,26 @@ public async Task<Holidays[]> GetAllHolidaysAsync(string id = "getHolidays", Can
9191
}
9292

9393
#region Timetable
94+
/// <summary>
95+
/// Get the timetable the user as their you logged in
96+
/// </summary>
97+
/// <param name="startDate">Start date of the timetable (default is the current date)</param>
98+
/// <param name="endDate">End date of the timetable (default is the current date)</param>
99+
/// <param name="id">Identier for the request</param>
100+
/// <param name="ct">Cancellation token</param>
101+
/// <returns>The periods for the user</returns>
102+
/// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
103+
/// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
104+
/// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
105+
/// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
106+
public async Task<Period[]> GetOwnTimetableAsync(DateTime startDate = default, DateTime endDate = default, string id = "GetTimtableForClass", CancellationToken ct = default)
107+
{
108+
if (UserType == Client.UserType.Student)
109+
return await GetTimetableForStudentAsync((Student)User, startDate, endDate, id, ct);
110+
else
111+
return await GetTimetableForTeacherAsync((Teacher)User, startDate, endDate, id, ct);
112+
}
113+
94114
/// <summary>
95115
/// Get the timetable for a class
96116
/// </summary>

0 commit comments

Comments
 (0)