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.cs43
1 files changed, 42 insertions, 1 deletions
diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs

index dee3913..05d0af9 100644 --- a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs +++ b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
@@ -1,6 +1,47 @@ +using System.Net.Http.Json; + namespace SafeNSound.Sdk; -public class SafeNSoundClient(SafeNSoundConfiguration config) +public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken) { + public WrappedHttpClient HttpClient { get; } = new() + { + BaseAddress = new Uri(config.BaseUri), + DefaultRequestHeaders = + { + Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken) + } + }; +#region Alarm + + public async Task<AlarmDto> GetAlarm(string userId = "@me") { + var res = await HttpClient.GetAsync($"/alarm/{userId}"); + res.EnsureSuccessStatusCode(); + return (await res.Content.ReadFromJsonAsync<AlarmDto>())!; + } + + public async Task SetAlarm(AlarmDto alarm) { + var res = await HttpClient.PutAsJsonAsync("/alarm/@me", alarm); + res.EnsureSuccessStatusCode(); + } + + public async Task DeleteAlarm(string userId = "@me") { + var res = await HttpClient.DeleteAsync($"/alarm/{userId}"); + res.EnsureSuccessStatusCode(); + } + + + +#endregion + +#region Budget + + + +#endregion +} + + +public class AlarmDto { } \ No newline at end of file