using System.Net.Http.Json; using Front.Program.Models; namespace Front.Program.Services; public class APIService { private readonly HttpClient _http; public APIService(HttpClient http) { _http = http; } private string ChangeToString(T data) { if (data == null) return string.Empty; var properties = typeof(T).GetProperties(); var value = properties.Select(p => $"{p.Name}={p.GetValue(data)}"); return string.Join("&", value); } public async Task?> GetJsonAsync(string url, TRequest value) { string parameter = ChangeToString(value); var response = await _http.GetFromJsonAsync>($"{url}?{parameter}"); return response; } }