Skip to content

Commit 6fa5d1e

Browse files
committed
Add holidays
1 parent 47b8791 commit 6fa5d1e

5 files changed

Lines changed: 93 additions & 5 deletions

File tree

API.Test/TimeTableTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,17 @@ public void GetCurrentSchoolYear()
6363
else
6464
Assert.Fail();
6565
}
66+
67+
[Test]
68+
public void GetHolidays()
69+
{
70+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
71+
72+
Task<Holidays[]> holidays = Client.GetAllHolidaysAsync();
73+
holidays.Wait();
74+
if (holidays.Result.Length > 0)
75+
Assert.Pass();
76+
else
77+
Assert.Fail();
78+
}
6679
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Diagnostics;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using WebUntisAPI.Client.Converter;
9+
10+
namespace WebUntisAPI.Client.Models
11+
{
12+
/// <summary>
13+
/// A holiday
14+
/// </summary>
15+
[DebuggerDisplay("Name = {LongName}")]
16+
public struct Holidays
17+
{
18+
/// <summary>
19+
/// The id of the holiday
20+
/// </summary>
21+
[JsonProperty("id")]
22+
public int Id { get; set; }
23+
24+
/// <summary>
25+
/// Short name of the holiday
26+
/// </summary>
27+
[JsonProperty("name")]
28+
public string Name { get; set; }
29+
30+
/// <summary>
31+
/// The normal name of the holiday
32+
/// </summary>
33+
[JsonProperty("longName")]
34+
public string LongName { get; set; }
35+
36+
/// <summary>
37+
/// The start date of the holiday
38+
/// </summary>
39+
[JsonProperty("startDate")]
40+
[JsonConverter(typeof(DateJsonConverter))]
41+
public DateTime StartDate { get; set; }
42+
43+
/// <summary>
44+
/// The end date of the holiday
45+
/// </summary>
46+
[JsonProperty("endDate")]
47+
[JsonConverter(typeof(DateJsonConverter))]
48+
public DateTime EndDate { get; set; }
49+
}
50+
}

WebUntisAPI.Client/Models/SchoolYearModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace WebUntisAPI.Client.Models
99
{
1010
internal struct SchoolYearModel
1111
{
12-
[JsonProperty("id")]
12+
[JsonProperty("schoolyearId")]
1313
public int Id { get; set; }
1414
}
1515
}

WebUntisAPI.Client/Models/StatusData.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,25 @@ public class StatusData
2121
public ForeBackColors LessonColors { get; set; }
2222

2323
/// <summary>
24-
/// idk
24+
/// Colors for a office hour
2525
/// </summary>
2626
public ForeBackColors OhColors { get; set; }
2727

2828
/// <summary>
29-
/// idk
29+
/// Colors for a standby
3030
/// </summary>
3131
public ForeBackColors SbColors { get; set; }
3232

3333
/// <summary>
34-
/// idk
34+
/// Colors for a break supervision
3535
/// </summary>
3636
public ForeBackColors BsColors { get; set; }
3737

38+
/// <summary>
39+
/// Colors for a examination
40+
/// </summary>
41+
public ForeBackColors ExColors { get; set; }
42+
3843
/// <summary>
3944
/// Colors for cancelled lessons
4045
/// </summary>

WebUntisAPI.Client/WebUntisClient.TimeTable.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,31 @@ public async Task<SchoolYear[]> GetAllSchoolYearsAsync(string id = "getSchoolyea
6565
/// </summary>
6666
/// <param name="id">Identifier for the request</param>
6767
/// <param name="ct">Cancellation token</param>
68-
/// <returns></returns>
68+
/// <returns>The current school year</returns>
69+
/// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
70+
/// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
71+
/// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
72+
/// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
6973
public async Task<SchoolYear> GetCurrentSchoolYearAsync(string id = "getCurrentSchoolyear", CancellationToken ct = default)
7074
{
7175
SchoolYear schoolYear = await MakeRequestAsync<object, SchoolYear>(id, "getCurrentSchoolyear", new object(), ct);
7276
return schoolYear;
7377
}
78+
79+
/// <summary>
80+
/// Get all holidays async
81+
/// </summary>
82+
/// <param name="id">Identifier for the request</param>
83+
/// <param name="ct">Cancellation token</param>
84+
/// <returns>All holidays</returns>
85+
/// <exception cref="ObjectDisposedException">Thrown when thew instance was disposed</exception>
86+
/// <exception cref="UnauthorizedAccessException">Thrown when you're not logged in</exception>
87+
/// <exception cref="HttpRequestException">Thrown when an error happend while the http request</exception>
88+
/// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
89+
public async Task<Holidays[]> GetAllHolidaysAsync(string id = "getHolidays", CancellationToken ct = default)
90+
{
91+
List<Holidays> holidays = await MakeRequestAsync<object, List<Holidays>>(id, "getHolidays", new object(), ct);
92+
return holidays.ToArray();
93+
}
7494
}
7595
}

0 commit comments

Comments
 (0)