1 files changed, 24 insertions, 7 deletions
diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs
index cbff880..f63d8b0 100644
--- a/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs
+++ b/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs
@@ -1,15 +1,16 @@
-using System.Text.Json.Serialization;
+using System.Net.Http.Json;
+using System.Text.Json.Serialization;
namespace SafeNSound.Sdk;
public class SafeNSoundAuthentication(SafeNSoundConfiguration config) {
- public async Task<SafeNSoundAuthResult> Register(RegisterDto registerDto) {
+ public async Task Register(RegisterDto registerDto) {
var hc = new WrappedHttpClient() {
BaseAddress = new Uri(config.BaseUri)
};
var res = await hc.PostAsJsonAsync("/auth/register", registerDto);
- return null!;
+ res.EnsureSuccessStatusCode();
}
public async Task<SafeNSoundAuthResult> Login(AuthDto authDto) {
@@ -18,17 +19,16 @@ public class SafeNSoundAuthentication(SafeNSoundConfiguration config) {
};
var res = await hc.PostAsJsonAsync("/auth/login", authDto);
- return null!;
+ return (await res.Content.ReadFromJsonAsync<SafeNSoundAuthResult>())!;
}
- public async Task<SafeNSoundAuthResult> Delete(AuthDto authDto) {
+ public async Task Delete(AuthDto authDto) {
var hc = new WrappedHttpClient() {
BaseAddress = new Uri(config.BaseUri)
};
var res = await hc.DeleteAsJsonAsync("/auth/delete", authDto);
res.EnsureSuccessStatusCode();
- return null!;
}
}
@@ -57,4 +57,21 @@ public class AuthDto {
public string Email { get; set; } = string.Empty;
}
-public class SafeNSoundAuthResult { }
\ No newline at end of file
+public class WhoAmI {
+ [JsonPropertyName("userId")]
+ public required string UserId { get; set; }
+
+ [JsonPropertyName("username")]
+ public required string UserName { get; set; }
+
+ [JsonPropertyName("deviceId")]
+ public required string DeviceId { get; set; }
+
+ [JsonPropertyName("type")]
+ public required string UserType { get; set; }
+}
+
+public class SafeNSoundAuthResult : WhoAmI {
+ [JsonPropertyName("accessToken")]
+ public required string AccessToken { get; set; }
+}
\ No newline at end of file
|