@@ -91,5 +91,172 @@ public async Task<Holidays[]> GetAllHolidaysAsync(string id = "getHolidays", Can
9191 List < Holidays > holidays = await MakeRequestAsync < object , List < Holidays > > ( id , "getHolidays" , new object ( ) , ct ) ;
9292 return holidays . ToArray ( ) ;
9393 }
94+
95+ #region Timetable
96+ /// <summary>
97+ /// Get the timetable for a class
98+ /// </summary>
99+ /// <param name="class">The class from the timetable</param>
100+ /// <param name="startDate">Start date of the timetable (default is the current date)</param>
101+ /// <param name="endDate">End date of the timetable (default is the current date)</param>
102+ /// <param name="id">Identier for the request</param>
103+ /// <param name="ct">Cancellation token</param>
104+ /// <returns>The periods for the class</returns>
105+ /// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
106+ /// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
107+ /// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
108+ /// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
109+ public async Task < Period [ ] > GetTimetableForClassAsync ( Class @class , DateTime startDate = default , DateTime endDate = default , string id = "GetTimtableForClass" , CancellationToken ct = default )
110+ {
111+ // Check for defaul time
112+ if ( startDate == default )
113+ startDate = DateTime . Now ;
114+
115+ if ( endDate == default )
116+ endDate = DateTime . Now ;
117+
118+ TimetableRequestModel requestModel = new TimetableRequestModel ( )
119+ {
120+ Id = @class . Id ,
121+ Type = 1 ,
122+ StartDate = startDate ,
123+ EndDate = endDate
124+ } ;
125+ List < Period > timetable = await MakeRequestAsync < TimetableRequestModel , List < Period > > ( id , "getTimetable" , requestModel , ct ) ;
126+ return timetable . ToArray ( ) ;
127+ }
128+
129+ /// <summary>
130+ /// Get the timetable for a teacher
131+ /// </summary>
132+ /// <param name="teacher">The teacher from the timetable</param>
133+ /// <param name="startDate">Start date of the timetable (default is the current date)</param>
134+ /// <param name="endDate">End date of the timetable (default is the current date)</param>
135+ /// <param name="id">Identier for the request</param>
136+ /// <param name="ct">Cancellation token</param>
137+ /// <returns>The periods for the teacher</returns>
138+ /// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
139+ /// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
140+ /// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
141+ /// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
142+ public async Task < Period [ ] > GetTimetableForTeacherAsync ( Teacher teacher , DateTime startDate = default , DateTime endDate = default , string id = "GetTimtableForTeacher" , CancellationToken ct = default )
143+ {
144+ // Check for defaul time
145+ if ( startDate == default )
146+ startDate = DateTime . Now ;
147+
148+ if ( endDate == default )
149+ endDate = DateTime . Now ;
150+
151+ TimetableRequestModel requestModel = new TimetableRequestModel ( )
152+ {
153+ Id = teacher . Id ,
154+ Type = 2 ,
155+ StartDate = startDate ,
156+ EndDate = endDate
157+ } ;
158+ List < Period > timetable = await MakeRequestAsync < TimetableRequestModel , List < Period > > ( id , "getTimetable" , requestModel , ct ) ;
159+ return timetable . ToArray ( ) ;
160+ }
161+
162+ /// <summary>
163+ /// Get the timetable for a subject
164+ /// </summary>
165+ /// <param name="subject">The subject from the timetable</param>
166+ /// <param name="startDate">Start date of the timetable (default is the current date)</param>
167+ /// <param name="endDate">End date of the timetable (default is the current date)</param>
168+ /// <param name="id">Identier for the request</param>
169+ /// <param name="ct">Cancellation token</param>
170+ /// <returns>The periods for the subject</returns>
171+ /// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
172+ /// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
173+ /// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
174+ /// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
175+ public async Task < Period [ ] > GetTimetableForSubjectAsync ( Subject subject , DateTime startDate = default , DateTime endDate = default , string id = "GetTimtableForSubject" , CancellationToken ct = default )
176+ {
177+ // Check for defaul time
178+ if ( startDate == default )
179+ startDate = DateTime . Now ;
180+
181+ if ( endDate == default )
182+ endDate = DateTime . Now ;
183+
184+ TimetableRequestModel requestModel = new TimetableRequestModel ( )
185+ {
186+ Id = subject . Id ,
187+ Type = 3 ,
188+ StartDate = startDate ,
189+ EndDate = endDate
190+ } ;
191+ List < Period > timetable = await MakeRequestAsync < TimetableRequestModel , List < Period > > ( id , "getTimetable" , requestModel , ct ) ;
192+ return timetable . ToArray ( ) ;
193+ }
194+
195+ /// <summary>
196+ /// Get the timetable for a room
197+ /// </summary>
198+ /// <param name="room">The room from the timetable</param>
199+ /// <param name="startDate">Start date of the timetable (default is the current date)</param>
200+ /// <param name="endDate">End date of the timetable (default is the current date)</param>
201+ /// <param name="id">Identier for the request</param>
202+ /// <param name="ct">Cancellation token</param>
203+ /// <returns>The periods for the room</returns>
204+ /// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
205+ /// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
206+ /// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
207+ /// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
208+ public async Task < Period [ ] > GetTimetableForRoomAsync ( Room room , DateTime startDate = default , DateTime endDate = default , string id = "GetTimtableForRoom" , CancellationToken ct = default )
209+ {
210+ // Check for defaul time
211+ if ( startDate == default )
212+ startDate = DateTime . Now ;
213+
214+ if ( endDate == default )
215+ endDate = DateTime . Now ;
216+
217+ TimetableRequestModel requestModel = new TimetableRequestModel ( )
218+ {
219+ Id = room . Id ,
220+ Type = 4 ,
221+ StartDate = startDate ,
222+ EndDate = endDate
223+ } ;
224+ List < Period > timetable = await MakeRequestAsync < TimetableRequestModel , List < Period > > ( id , "getTimetable" , requestModel , ct ) ;
225+ return timetable . ToArray ( ) ;
226+ }
227+
228+ /// <summary>
229+ /// Get the timetable for a student
230+ /// </summary>
231+ /// <param name="student">The student from the timetable</param>
232+ /// <param name="startDate">Start date of the timetable (default is the current date)</param>
233+ /// <param name="endDate">End date of the timetable (default is the current date)</param>
234+ /// <param name="id">Identier for the request</param>
235+ /// <param name="ct">Cancellation token</param>
236+ /// <returns>The periods for the student</returns>
237+ /// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
238+ /// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
239+ /// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
240+ /// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
241+ public async Task < Period [ ] > GetTimetableForStudentAsync ( Student student , DateTime startDate = default , DateTime endDate = default , string id = "GetTimtableForStudent" , CancellationToken ct = default )
242+ {
243+ // Check for defaul time
244+ if ( startDate == default )
245+ startDate = DateTime . Now ;
246+
247+ if ( endDate == default )
248+ endDate = DateTime . Now ;
249+
250+ TimetableRequestModel requestModel = new TimetableRequestModel ( )
251+ {
252+ Id = student . Id ,
253+ Type = 5 ,
254+ StartDate = startDate ,
255+ EndDate = endDate
256+ } ;
257+ List < Period > timetable = await MakeRequestAsync < TimetableRequestModel , List < Period > > ( id , "getTimetable" , requestModel , ct ) ;
258+ return timetable . ToArray ( ) ;
259+ }
260+ #endregion
94261 }
95262}
0 commit comments