From 6f3f08ed340e59a62a2d0428a5c32f99551ef1ce Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 3 Jun 2025 01:01:40 +0200 Subject: Fix performance issues, add fake user bot to test client, more testing --- testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs') 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>())!; } + + public async Task DeleteAccount(AuthDto auth) { + var res = await HttpClient.DeleteAsJsonAsync("/auth/delete", auth); + res.EnsureSuccessStatusCode(); + } + + public async Task> GetAssignedUsers() { + var res = await HttpClient.GetAsync("/monitor/assignedUsers"); + res.EnsureSuccessStatusCode(); + return (await res.Content.ReadFromJsonAsync>())!; + } + + 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 GetAllUserIdsEnumerable() { + var res = await HttpClient.GetAsync($"/admin/allUserIds"); + res.EnsureSuccessStatusCode(); + await foreach (var item in res.Content.ReadFromJsonAsAsyncEnumerable()) { + 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 -- cgit 1.5.1