namespace YPS.Beer.Services; public class PunkService : IPunkService { private readonly HttpClient _httpClient; public PunkService(HttpClient httpClient) { _httpClient = httpClient; } public async Task GetBeer(int id) { var beer = await _httpClient.GetFromJsonAsync($"beers/{id}"); return beer?.SingleOrDefault(); } public async Task> GetBeers(params int[] ids) { var beers = new List(); foreach (var id in ids) { var beer = await GetBeer(id); if (beer is not null) beers.Add(beer); } return beers; } public async Task> FindBeers(string search) { search = search.Replace(' ', '_'); var beers = await _httpClient.GetFromJsonAsync($"beers?beer_name={search}"); if (beers is null) throw new Exception(); return beers; } }