Skip to content

Commit 8815a66

Browse files
committed
Add get class teachers method
1 parent 7e58baf commit 8815a66

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

WebUntisAPI.Client/Models/Class.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
using System.Collections.Generic;
44
using System.Diagnostics;
55
using System.Linq;
6+
using System.Net.Http;
67
using System.Text;
8+
using System.Threading;
79
using System.Threading.Tasks;
810
using WebUntisAPI.Client.Converter;
11+
using WebUntisAPI.Client.Exceptions;
912

1013
namespace WebUntisAPI.Client.Models
1114
{
@@ -41,5 +44,21 @@ public struct Class
4144
/// An array of all teachers of the class
4245
/// </summary>
4346
public int[] Teachers { get; set; }
47+
48+
/// <summary>
49+
/// Get all taechers of this class
50+
/// </summary>
51+
/// <param name="client">The client for the request (This should be the same client with that you requested the class)</param>
52+
/// <param name="id">Identifier for the request</param>
53+
/// <param name="ct">Cancellation token</param>
54+
/// <returns>The teachers of the class</returns>
55+
/// <exception cref="UnauthorizedAccessException">Thrown when the client aren't not logged in</exception>
56+
/// <exception cref="HttpRequestException">Thrown when there was an error while the http request</exception>
57+
/// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
58+
public async Task<Teacher[]> GetTeachersAsync(WebUntisClient client, string id = "getClassTeachers", CancellationToken ct = default)
59+
{
60+
int[] classTeachers = Teachers;
61+
return (await client.GetAllTeachersAsync(id, ct)).Where(t => classTeachers.Contains(t.Id)).ToArray();
62+
}
4463
}
4564
}

0 commit comments

Comments
 (0)