Skip to content

Commit 8bd83d8

Browse files
committed
Add get curretn school year method and move SchoolYear in the correct folder
1 parent 89a4b48 commit 8bd83d8

4 files changed

Lines changed: 31 additions & 2 deletions

File tree

API.Test/TimeTableTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq;
55
using System.Text;
66
using System.Threading.Tasks;
7-
using WebUntisAPI.Client;
87
using WebUntisAPI.Client.Models;
98
using static API.Test.AuthentificationTests;
109

@@ -51,4 +50,17 @@ public void GetSchoolYears()
5150
else
5251
Assert.Fail();
5352
}
53+
54+
[Test]
55+
public void GetCurrentSchoolYear()
56+
{
57+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
58+
59+
Task<SchoolYear> schoolYear = Client.GetCurrentSchoolYearAsync();
60+
schoolYear.Wait();
61+
if (schoolYear.Result != null)
62+
Assert.Pass();
63+
else
64+
Assert.Fail();
65+
}
5466
}

WebUntisAPI.Client/Converter/SchoolYearJsonConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Text;
77
using System.Threading.Tasks;
88
using WebUntisAPI.Client.Extensions;
9+
using WebUntisAPI.Client.Models;
910

1011
namespace WebUntisAPI.Client.Converter
1112
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using System.Threading.Tasks;
99
using WebUntisAPI.Client.Converter;
1010

11-
namespace WebUntisAPI.Client
11+
namespace WebUntisAPI.Client.Models
1212
{
1313
/// <summary>
1414
/// A school year

WebUntisAPI.Client/WebUntisClient.TimeTable.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,26 @@ public async Task<Timegrid> GetTimegridAsync(string id = "getTimegrid", Cancella
5050
/// <param name="id">Identifier for the request</param>
5151
/// <param name="ct">Cancellation token</param>
5252
/// <returns>All school years</returns>
53+
/// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
54+
/// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
55+
/// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
56+
/// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
5357
public async Task<SchoolYear[]> GetAllSchoolYearsAsync(string id = "getSchoolyears", CancellationToken ct = default)
5458
{
5559
List<SchoolYear> schoolYears = await MakeRequestAsync<object, List<SchoolYear>>(id, "getSchoolyears", new object(), ct);
5660
return schoolYears.ToArray();
5761
}
62+
63+
/// <summary>
64+
/// Get the current school year
65+
/// </summary>
66+
/// <param name="id">Identifier for the request</param>
67+
/// <param name="ct">Cancellation token</param>
68+
/// <returns></returns>
69+
public async Task<SchoolYear> GetCurrentSchoolYearAsync(string id = "getCurrentSchoolyear", CancellationToken ct = default)
70+
{
71+
SchoolYear schoolYear = await MakeRequestAsync<object, SchoolYear>(id, "getCurrentSchoolyear", new object(), ct);
72+
return schoolYear;
73+
}
5874
}
5975
}

0 commit comments

Comments
 (0)