summary refs log tree commit diff
path: root/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs')
-rw-r--r--testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs

index c6f16f2..8291178 100644 --- a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs +++ b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
@@ -1,4 +1,5 @@ using System.Net.Http.Json; +using System.Text.Json.Nodes; using System.Text.Json.Serialization; namespace SafeNSound.Sdk; @@ -54,10 +55,47 @@ public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken res.EnsureSuccessStatusCode(); return (await res.Content.ReadFromJsonAsync<Dictionary<string, AlarmDto>>())!; } + + public async Task DeleteAccount(AuthDto auth) { + var res = await HttpClient.DeleteAsJsonAsync("/auth/delete", auth); + res.EnsureSuccessStatusCode(); + } + + public async Task<List<string>> GetAssignedUsers() { + var res = await HttpClient.GetAsync("/monitor/assignedUsers"); + res.EnsureSuccessStatusCode(); + return (await res.Content.ReadFromJsonAsync<List<string>>())!; + } + + public async Task AddAssignedUser(string targetUserId) { + var res = await HttpClient.PatchAsJsonAsync("/monitor/assignedUsers", new { userId = targetUserId }); + res.EnsureSuccessStatusCode(); + } + + public async Task RemoveAssignedUser(string targetUserId) { + var res = await HttpClient.DeleteAsJsonAsync($"/monitor/assignedUsers", new { userId = targetUserId }); + res.EnsureSuccessStatusCode(); + } + + public async IAsyncEnumerable<string> GetAllUserIdsEnumerable() { + var res = await HttpClient.GetAsync($"/admin/allUserIds"); + res.EnsureSuccessStatusCode(); + await foreach (var item in res.Content.ReadFromJsonAsAsyncEnumerable<string>()) { + yield return item!; + } + } + + public async Task MonitorAllUsers() { + var res = await HttpClient.PostAsync("/admin/monitorAllUsers", null); + res.EnsureSuccessStatusCode(); + } } public class AlarmDto { [JsonPropertyName("reason")] public required string Reason { get; set; } + + [JsonPropertyName("createdAt")] + public DateTime CreatedAt { get; set; } } \ No newline at end of file