Refactor and expose more information
This commit was merged in pull request #1.
This commit is contained in:
22
HomeApi/Integration/WeatherService.cs
Normal file
22
HomeApi/Integration/WeatherService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using HomeApi.Integration.Client;
|
||||
using HomeApi.Models.Configuration;
|
||||
using HomeApi.Models.Response;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace HomeApi.Integration;
|
||||
|
||||
public interface IWeatherService
|
||||
{
|
||||
Task<WeatherData> GetWeatherAsync(string lat, string lon);
|
||||
}
|
||||
|
||||
public class WeatherService(IWeatherClient weatherApi, IOptions<ApiConfiguration> options) : IWeatherService
|
||||
{
|
||||
private readonly ApiConfiguration _apiConfig = options.Value;
|
||||
|
||||
public Task<WeatherData> GetWeatherAsync(string lat, string lon)
|
||||
{
|
||||
var location = $"{lat},{lon}";
|
||||
return weatherApi.GetForecastAsync(_apiConfig.Keys.Weather, location);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user