summary refs log tree commit diff
path: root/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-06-03 23:38:36 +0200
committerRory& <root@rory.gay>2025-06-03 23:38:50 +0200
commit7ed1b77457f5e41ec5f7ba8e102f13f69380608d (patch)
tree22cbb57a43dfae7cc4458c1e13b3b5ae20595815 /testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
parentPrepare for budgeting, move to native createdAt (diff)
downloadnodejs-final-assignment-7ed1b77457f5e41ec5f7ba8e102f13f69380608d.tar.xz
Implement budget handling
Diffstat (limited to 'testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs')
-rw-r--r--testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs21
1 files changed, 8 insertions, 13 deletions
diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs

index 4376d3f..e1564db 100644 --- a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs +++ b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
@@ -119,15 +119,20 @@ public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken res.EnsureSuccessStatusCode(); } - public async Task AddBudget(string userId, BudgetWithReason budget) { + public async Task AddBudget(string userId, BudgetHistoryEntry budget) { var res = await HttpClient.PatchAsJsonAsync($"/user/{userId}/budget", budget); res.EnsureSuccessStatusCode(); } + + public async Task SpendBudget(BudgetHistoryEntry budget) { + var res = await HttpClient.PatchAsJsonAsync($"/budget/@me", budget); + res.EnsureSuccessStatusCode(); + } public async Task<BudgetWithHistory> GetBudget(string userId = "@me") { var res = await HttpClient.GetAsync( userId == "@me" - ? $"/budget" + ? $"/budget/@me" : $"/user/{userId}/budget" ); res.EnsureSuccessStatusCode(); @@ -157,16 +162,6 @@ public class DeviceDto { public DateTime LastSeen { get; set; } } -public class Budget { - [JsonPropertyName("budget")] - public double Amount { get; set; } -} - -public class BudgetWithReason : Budget { - [JsonPropertyName("reason")] - public string? Reason { get; set; } -} - public class BudgetWithHistory { [JsonPropertyName("budget")] public double Amount { get; set; } @@ -186,5 +181,5 @@ public class BudgetHistoryEntry { public string Reason { get; set; } [JsonPropertyName("createdAt")] - public DateTime CreatedAt { get; set; } + public DateTime? CreatedAt { get; set; } } \ No newline at end of file