using System.Text.Json; using PaydayFrontend.Models; namespace PaydayFrontend.Services; public interface IBankService { public Task> GetAllBanks(); public Task> GetOffers(long directionId); } public class BankService : IBankService { private readonly HttpClient _httpClient; public BankService(HttpClient httpClient) { _httpClient = httpClient; _httpClient.BaseAddress = new Uri("https://payday.zetcraft.ru"); } public async Task> GetAllBanks() { var response = await _httpClient.GetAsync("v1/admin/banks"); var result = await response.Content.ReadAsStringAsync(); var banks = JsonSerializer.Deserialize>(result, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); return banks; } public async Task> GetOffers(long directionId) { var response = await _httpClient.GetAsync("v1/public/credit/direction/" + directionId); var result = await response.Content.ReadAsStringAsync(); var offers = JsonSerializer.Deserialize>(result, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); return offers; } }