Skip to content

Commit cb1636f

Browse files
committed
Merge branch 'release/v1.2.0'
2 parents 05363e0 + 359204a commit cb1636f

16 files changed

Lines changed: 851 additions & 51 deletions

API.Test/AuthentificationTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ static AuthentificationTests()
1717
{
1818
// Load a file where i saved login data
1919
using StreamReader str = new("LoginData.txt");
20-
s_Server = str.ReadLine();
21-
s_LoginName = str.ReadLine();
22-
s_UserName = str.ReadLine();
23-
s_Password = str.ReadLine();
20+
s_Server = str.ReadLine()!;
21+
s_LoginName = str.ReadLine()!;
22+
s_UserName = str.ReadLine()!;
23+
s_Password = str.ReadLine()!;
2424
}
2525

2626
// Login data to test

API.Test/MessagesTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ public void GetReceptionPeople()
8888
Assert.Fail();
8989
}
9090

91+
[Test]
92+
public void GetStaffFilters()
93+
{
94+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
95+
96+
Task<Dictionary<string, FilterItem[]>> filters = Client.GetStaffSearchFiltersAsync();
97+
filters.Wait();
98+
99+
if (filters.Result.Count > 0)
100+
Assert.Pass();
101+
else
102+
Assert.Fail();
103+
}
104+
91105
[Test]
92106
public void GetDrafts()
93107
{

API.Test/ProfileTests.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using static API.Test.AuthentificationTests;
7+
using SixLabors.ImageSharp;
8+
using WebUntisAPI.Client.Models;
9+
10+
namespace API.Test;
11+
12+
[TestFixture]
13+
internal class ProfileTests
14+
{
15+
[Test]
16+
public void GetRecipientProfileImgTest()
17+
{
18+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
19+
20+
Task<Image> imgRender = Client.GetMessagePersonProfileImageAsync(new() { DisplayName = "Test Person" });
21+
imgRender.Wait();
22+
imgRender.Result.SaveAsPng("RenderImg.png");
23+
24+
Task<Image> imgDownload = Client.GetMessagePersonProfileImageAsync(new() { ImageUrl = new("https://foundations.projectpythia.org/_images/GitHub-logo.png") }); // A Random non square GitHub image i found
25+
imgDownload.Wait();
26+
imgDownload.Result.SaveAsPng("DownloadImg.png");
27+
}
28+
29+
[Test]
30+
public void GetSupportedLanguages()
31+
{
32+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
33+
34+
Task<Dictionary<string, string>> languages = Client.GetAvailableLanguagesAsync();
35+
languages.Wait();
36+
37+
if (languages.Result.Count > 0)
38+
Assert.Pass();
39+
else
40+
Assert.Fail();
41+
}
42+
43+
[Test]
44+
public void GetAccountConfiguration()
45+
{
46+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
47+
48+
Task<AccountConfig> accountConfig = Client.GetAccountConfigAsync();
49+
accountConfig.Wait();
50+
51+
if (accountConfig.Result is not null)
52+
Assert.Pass();
53+
else
54+
Assert.Fail();
55+
}
56+
57+
[Test]
58+
public void GetGenerallyInformation()
59+
{
60+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
61+
62+
Task<GeneralAccount> account = Client.GetGenerallyAccountInformationAsync();
63+
account.Wait();
64+
65+
if (account.Result is not null)
66+
Assert.Pass();
67+
else
68+
Assert.Fail();
69+
}
70+
71+
[Test]
72+
public void GetContactDetails()
73+
{
74+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
75+
76+
Task<(ContactDetails? contact, bool read, bool write)> contact = Client.GetContactDetailsAsync();
77+
contact.Wait();
78+
79+
if (contact.Result.read)
80+
Assert.Pass();
81+
else
82+
Assert.Fail();
83+
}
84+
85+
[Test]
86+
public void GetOwnProfileImage()
87+
{
88+
Client.LoginAsync(s_Server, s_LoginName, s_UserName, s_Password).Wait();
89+
90+
Task<(Image? image, bool read, bool write)> image = Client.GetOwnProfileImageAsync();
91+
image.Wait();
92+
93+
image.Result.image.SaveAsPngAsync("ProfileImg.png");
94+
}
95+
}

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ This .NET library allows you to connect you with a WebUntis account and load all
99
## Documentation:
1010
The documentation is integrated in the package so that all classes and methods explain what they do. Here're the basics to use the library:
1111

12+
## Licence:
13+
When your project has .NET 6 or greater as target you must be ensure that your project also agrees the [Six Labors Split License](https://www.nuget.org/packages/SixLabors.ImageSharp/3.0.1/License) as [Transitive Package Dependency](https://en.wikipedia.org/wiki/Transitive_dependency).
14+
This is in cause of that this package use in .NET 6 or greater the packages [SixLabors.ImageSharp](https://www.nuget.org/packages/SixLabors.ImageSharp) and [SixLabors.ImageSharp.Drawing](https://www.nuget.org/packages/SixLabors.ImageSharp.Drawing) for dynamic image loading and rendering.
15+
1216
### 1. Add references to this library
1317
The simplest way is to add the [NuGet](https://www.nuget.org/packages/Suiram1.WebUntisAPI.Client) package to your project,
14-
but when you don't want to use NuGet you can also download the [binarys](https://github.com/Suiram1701/WebUntisAPI.Client/releases) of the package and add the reference the contained .dll
18+
but when you don't want to use NuGet you can also download the [binaries](https://github.com/Suiram1701/WebUntisAPI.Client/releases) of the package and add the reference the contained .dll
1519

1620
### 2. Creating a client and login:
1721

@@ -30,8 +34,8 @@ Remarks:
3034
- Under no circumstances should 10 req. per sec., more than 1800req. per hr (but in no case more than 3600 req. per hr). If the specifications are exceeded, access to WebUntis could permanently blocked by the WebUntis API.
3135

3236
### 3. Send requests
33-
After your login you can send requests to get informations about your timetable and all about.
34-
The methods an what they do shoud be self-explained.
37+
After your login you can send requests to get information about your timetable and all about.
38+
The methods an what they do should be self-explained.
3539

3640
## Issues
3741
When you had an error that you don't understand or you don't understand how you can use the library you can create an issue so that I can help you by your problem.

WebUntisAPI.Client/Converter/TimeJsonConverter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ public override void WriteJson(JsonWriter writer, DateTime value, JsonSerializer
1919
writer.WriteValue(timeString);
2020
}
2121
}
22-
}
23-
22+
}

WebUntisAPI.Client/Extensions/ColorExtensions.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace WebUntisAPI.Client.Extensions
1010
public static class ColorExtensions
1111
{
1212
/// <summary>
13-
/// Convert a color instance to the Hexadeciaml format: RRGGBB
13+
/// Convert a color instance to the Hexadecimal format: RRGGBB
1414
/// </summary>
1515
/// <param name="color"></param>
1616
/// <returns>The color string</returns>
@@ -22,11 +22,11 @@ public static string ToHexColorFormat(this Color color)
2222
/// <summary>
2323
/// Convert a color string to the Hexadecimal format: RRGGBB
2424
/// </summary>
25-
/// <param name="color"></param>
25+
/// <param name="_"></param>
2626
/// <param name="colorString">The string to convert</param>
2727
/// <returns>The created color</returns>
2828
/// <exception cref="ArgumentException">Thrown when the <paramref name="colorString"/> isn't in the correct format</exception>
29-
public static Color FromHexColorFormat(this Color color, string colorString)
29+
public static Color FromHexColorFormat(this Color _, string colorString)
3030
{
3131
if (!Regex.IsMatch(colorString, @"[\da-fA-F]{6}"))
3232
throw new ArgumentException("The color string isn't in a correct format", nameof(colorString));
@@ -39,5 +39,4 @@ public static Color FromHexColorFormat(this Color color, string colorString)
3939
return Color.FromArgb(red, green, blue);
4040
}
4141
}
42-
43-
}
42+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Newtonsoft.Json;
2+
3+
namespace WebUntisAPI.Client.Models
4+
{
5+
/// <summary>
6+
/// Account configuration details
7+
/// </summary>
8+
public class AccountConfig
9+
{
10+
/// <summary>
11+
/// Can display the contact details for this account
12+
/// </summary>
13+
[JsonProperty("canReadContactDetail")]
14+
public bool CanReadContactDetails { get; set; } = false;
15+
}
16+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using Newtonsoft.Json;
2+
3+
namespace WebUntisAPI.Client.Models
4+
{
5+
/// <summary>
6+
/// Contact information about a user
7+
/// </summary>
8+
public class ContactDetails
9+
{
10+
/// <summary>
11+
/// The person id
12+
/// </summary>
13+
[JsonProperty("personId")]
14+
public int PersonId { get; set; }
15+
16+
/// <summary>
17+
/// The person type id
18+
/// </summary>
19+
[JsonProperty("personType")]
20+
public int PersonType { get; set; }
21+
22+
/// <summary>
23+
/// The user id
24+
/// </summary>
25+
[JsonProperty("id")]
26+
public int Id { get; set; }
27+
28+
/// <summary>
29+
/// The user name
30+
/// </summary>
31+
[JsonProperty("name")]
32+
public string Name { get; set; }
33+
34+
/// <summary>
35+
/// For which person are this information
36+
/// </summary>
37+
[JsonProperty("addressType")]
38+
public string AddressType { get; set; }
39+
40+
/// <summary>
41+
/// The id for <see cref="AddressType"/>
42+
/// </summary>
43+
[JsonProperty("addressTypeValue")]
44+
public int AddressTypeValue { get; set; }
45+
46+
/// <summary>
47+
/// The street
48+
/// </summary>
49+
[JsonProperty("street")]
50+
public string Street { get; set; }
51+
52+
/// <summary>
53+
/// The city
54+
/// </summary>
55+
[JsonProperty("city")]
56+
public string City { get; set; }
57+
58+
/// <summary>
59+
/// The post code
60+
/// </summary>
61+
[JsonProperty("postCode")]
62+
public string PostCode { get; set; }
63+
64+
/// <summary>
65+
/// The country
66+
/// </summary>
67+
[JsonProperty("country")]
68+
public string Country { get; set; }
69+
70+
/// <summary>
71+
/// The email
72+
/// </summary>
73+
[JsonProperty("email")]
74+
public string Email { get; set; }
75+
76+
/// <summary>
77+
/// The phone number
78+
/// </summary>
79+
[JsonProperty("phone")]
80+
public string PhoneNumber { get; set; }
81+
82+
/// <summary>
83+
/// The mobile number
84+
/// </summary>
85+
[JsonProperty("mobile")]
86+
public string MobileNumber { get; set; }
87+
88+
/// <summary>
89+
/// The fax number
90+
/// </summary>
91+
[JsonProperty("fax")]
92+
public string FaxNumber { get; set; }
93+
}
94+
}

0 commit comments

Comments
 (0)