From 784cb47ceb905abacc3a9bd66d5818fb88ea95a4 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 3 Jun 2025 21:28:05 +0200 Subject: testFrontend: add activity for almost all endpoints --- testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs | 27 +++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs') 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 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())!; } - public async Task SetAlarm(AlarmDto alarm, string userId = "@me") { - var res = await HttpClient.PutAsJsonAsync("/alarm/@me", alarm); + public async Task 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()); } 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 { -- cgit 1.5.1