using System.Net.Http.Json; namespace HyperBooru.ApiClient; public class User { private HBSession session; internal User(HBSession session) => this.session = session; public async Task GetAllUsersAsync() => (await session.HttpClient.GetFromJsonAsync("/api/user"))!; public async Task GetUserAsync(Guid userId) => (await session.HttpClient.GetFromJsonAsync($"/api/user/{userId}"))!; public async Task CreateUserAsync(string username, string password) { var user = new ApiModels.UserCreateRequest() { Username = username, Password = password }; var response = await session.HttpClient.PostAsJsonAsync("/api/user", user); return (await response.Content.ReadFromJsonAsync())!; } public async Task UpdateUserAsync(Guid userId, string? username, string? password) { var user = new ApiModels.UserUpdateRequest() { Username = username, Password = password }; var response = await session.HttpClient.PatchAsJsonAsync($"/api/user/{userId}", user); return (await response.Content.ReadFromJsonAsync())!; } public async Task DeleteUserAsync(Guid userId) => (await session.HttpClient.DeleteFromJsonAsync($"/api/user/{userId}"))!; }