From 6a830e02b1c1873c77907e7a88c2143a351adea4 Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 11 Jun 2025 10:47:15 +0200 Subject: Finish demo --- testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs') diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs index 3cd5d5c..b5bca12 100644 --- a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs +++ b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs @@ -66,12 +66,14 @@ public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken res.EnsureSuccessStatusCode(); } - public async Task GetBudget(string userId = "@me") { - var res = await HttpClient.GetAsync( - userId == "@me" - ? $"/budget/@me" - : $"/user/{userId}/budget" - ); + public async Task GetBudget() { + var res = await HttpClient.GetAsync($"/budget/@me"); + res.EnsureSuccessStatusCode(); + return (await res.Content.ReadFromJsonAsync())!; + } + + public async Task GetBudget(string userId) { + var res = await HttpClient.GetAsync($"/user/{userId}/budget"); res.EnsureSuccessStatusCode(); return (await res.Content.ReadFromJsonAsync())!; } @@ -143,7 +145,7 @@ public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken public class AlarmDto { [JsonPropertyName("_id")] public string? Id { get; set; } - + [JsonPropertyName("reason")] public required string Reason { get; set; } @@ -165,8 +167,13 @@ public class DeviceDto { public DateTime LastSeen { get; set; } } +public class CurrentBalance { + [JsonPropertyName("currentBalance")] + public double Amount { get; set; } +} + public class BudgetWithHistory { - [JsonPropertyName("budget")] + [JsonPropertyName("balance")] public double Amount { get; set; } [JsonPropertyName("history")] -- cgit 1.5.1