summary refs log tree commit diff
path: root/testFrontend/SafeNSound.Sdk
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-06-11 10:47:15 +0200
committerRory& <root@rory.gay>2025-06-11 10:47:15 +0200
commit6a830e02b1c1873c77907e7a88c2143a351adea4 (patch)
tree10761b7d0dccb5c8859ee13c4aafae385218345c /testFrontend/SafeNSound.Sdk
parentAdd initial demo (diff)
downloadnodejs-final-assignment-demo.tar.xz
Finish demo demo
Diffstat (limited to 'testFrontend/SafeNSound.Sdk')
-rw-r--r--testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs23
1 files changed, 15 insertions, 8 deletions
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<BudgetWithHistory> GetBudget(string userId = "@me") { - var res = await HttpClient.GetAsync( - userId == "@me" - ? $"/budget/@me" - : $"/user/{userId}/budget" - ); + public async Task<CurrentBalance> GetBudget() { + var res = await HttpClient.GetAsync($"/budget/@me"); + res.EnsureSuccessStatusCode(); + return (await res.Content.ReadFromJsonAsync<CurrentBalance>())!; + } + + public async Task<BudgetWithHistory> GetBudget(string userId) { + var res = await HttpClient.GetAsync($"/user/{userId}/budget"); res.EnsureSuccessStatusCode(); return (await res.Content.ReadFromJsonAsync<BudgetWithHistory>())!; } @@ -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")]