1 files changed, 21 insertions, 6 deletions
diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
index 9ea8073..8b06c30 100644
--- a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
+++ b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
@@ -20,19 +20,29 @@ public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken
#region Alarm
- public async Task<AlarmDto> GetAlarm(string userId = "@me") {
- var res = await HttpClient.GetAsync($"/alarm/{userId}");
+ public async Task SetAlarm(AlarmDto alarm) {
+ var res = await HttpClient.PutAsJsonAsync("/alarm/@me", alarm);
res.EnsureSuccessStatusCode();
- return (await res.Content.ReadFromJsonAsync<AlarmDto>())!;
}
- public async Task SetAlarm(AlarmDto alarm, string userId = "@me") {
- var res = await HttpClient.PutAsJsonAsync("/alarm/@me", alarm);
+ public async Task<AlarmDto?> GetAlarm(string userId = "@me") {
+ var res = await HttpClient.GetAsync(
+ // required due to express routing not being closest-match
+ userId == "@me"
+ ? $"/alarm/@me"
+ : $"/user/{userId}/alarm"
+ );
res.EnsureSuccessStatusCode();
+ return (await res.Content.ReadFromJsonAsync<AlarmDto?>());
}
public async Task DeleteAlarm(string userId = "@me") {
- var res = await HttpClient.DeleteAsync($"/alarm/{userId}");
+ var res = await HttpClient.DeleteAsync(
+ // required due to express routing not being closest-match
+ userId == "@me"
+ ? $"/alarm/@me"
+ : $"/user/{userId}/alarm"
+ );
res.EnsureSuccessStatusCode();
}
@@ -103,6 +113,11 @@ public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken
var res = await HttpClient.PatchAsJsonAsync($"/auth/devices/{deviceId}", device);
res.EnsureSuccessStatusCode();
}
+
+ public async Task LogOut() {
+ var res = await HttpClient.PostAsync("/auth/logout", null);
+ res.EnsureSuccessStatusCode();
+ }
}
public class AlarmDto {
|