From 4e12e02bc805170e6b03d33e0ef894b2a3021fb3 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 1 Jun 2025 11:13:55 +0200 Subject: Add alarm endpoints, basic budget routes, spend history --- testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs | 43 ++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs') 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 GetAlarm(string userId = "@me") { + var res = await HttpClient.GetAsync($"/alarm/{userId}"); + res.EnsureSuccessStatusCode(); + return (await res.Content.ReadFromJsonAsync())!; + } + + 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 -- cgit 1.5.1