Add image generation (#2)
* Add image generation * Optimise for minimal memory * Added a new ui * Add support for esp
This commit was merged in pull request #2.
This commit is contained in:
@@ -12,6 +12,14 @@ public class AuroraService(IAuroraClient auroraApi) : IAuroraService
|
||||
{
|
||||
public Task<AuroraForecastApiResponse> GetAuroraForecastAsync(string lat, string lon)
|
||||
{
|
||||
return auroraApi.GetForecastAsync(latitude: lat, longitude: lon);
|
||||
try
|
||||
{
|
||||
return auroraApi.GetForecastAsync(latitude: lat, longitude: lon);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
HomeApi/Integration/Client/ResRobotClient.cs
Normal file
30
HomeApi/Integration/Client/ResRobotClient.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using HomeApi.Models.Response;
|
||||
using Refit;
|
||||
|
||||
namespace HomeApi.Integration.Client;
|
||||
|
||||
public interface IResRobotClient
|
||||
{
|
||||
[Get("/v2.1/departureBoard")]
|
||||
Task<TrafikLabsApiResponse> GetDepartureBoardAsync(
|
||||
[AliasAs("accessId")] string accessId,
|
||||
[AliasAs("id")] string stopId,
|
||||
[AliasAs("direction")] string direction = null,
|
||||
[AliasAs("date")] string date = null, // Format: YYYY-MM-DD
|
||||
[AliasAs("time")] string time = null, // Format: HH:MM
|
||||
[AliasAs("duration")] int? duration = null,
|
||||
[AliasAs("maxJourneys")] int? maxJourneys = null,
|
||||
[AliasAs("operators")] string operators = null, // Example: "275,287"
|
||||
[AliasAs("products")] int? products = null,
|
||||
[AliasAs("passlist")] int? passlist = 0,
|
||||
[AliasAs("lang")] string language = "sv",
|
||||
[AliasAs("format")] string format = "json"
|
||||
);
|
||||
|
||||
[Get("/v2.1/location.name")]
|
||||
Task<LocationNameResponse> GetLocationsByNameAsync(
|
||||
[AliasAs("input")] string input,
|
||||
[AliasAs("format")] string format = "json",
|
||||
[AliasAs("accessId")] string accessId = "YOUR_API_KEY"
|
||||
);
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
using HomeApi.Models.Response;
|
||||
|
||||
namespace HomeApi.Integration.Client;
|
||||
|
||||
using Refit;
|
||||
|
||||
namespace HomeApi.Integration.Client.WeatherClient;
|
||||
|
||||
public interface IWeatherClient
|
||||
{
|
||||
[Get("/forecast.json")]
|
||||
Task<WeatherData> GetForecastAsync(
|
||||
[AliasAs("key")] string apiKey,
|
||||
[AliasAs("q")] string coordinates,
|
||||
[AliasAs("days")] int days = 7,
|
||||
[AliasAs("days")] int days = 14,
|
||||
[AliasAs("lang")] string language = "sv",
|
||||
[AliasAs("aqi")] string aqi = "yes",
|
||||
[AliasAs("alerts")] string alerts = "yes");
|
||||
46
HomeApi/Integration/DepartureBoardService.cs
Normal file
46
HomeApi/Integration/DepartureBoardService.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using HomeApi.Extensions;
|
||||
using HomeApi.Integration.Client;
|
||||
using HomeApi.Models;
|
||||
using HomeApi.Models.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace HomeApi.Integration;
|
||||
|
||||
public interface IDepartureBoardService
|
||||
{
|
||||
Task<List<TimeTable>?> GetDepartureBoard();
|
||||
}
|
||||
|
||||
public class DepartureBoardService(IResRobotClient departureBoardApi, IOptions<ApiConfiguration> options) : IDepartureBoardService
|
||||
{
|
||||
private readonly ApiConfiguration _apiConfig = options.Value;
|
||||
|
||||
public async Task<List<TimeTable>?> GetDepartureBoard()
|
||||
{
|
||||
var locationResponse = await departureBoardApi.GetLocationsByNameAsync(
|
||||
input: _apiConfig.DefaultStation,
|
||||
format: "json",
|
||||
accessId: _apiConfig.Keys.ResRobot
|
||||
);
|
||||
|
||||
var id = locationResponse.StopLocationOrCoordLocation.FirstOrDefault()?.StopLocation?.ExtId;
|
||||
|
||||
if (id == null)
|
||||
return null;
|
||||
|
||||
var result = await departureBoardApi.GetDepartureBoardAsync(
|
||||
accessId: _apiConfig.Keys.ResRobot,
|
||||
stopId: id,
|
||||
direction: null,
|
||||
date: DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
time: DateTime.Now.ToString("HH:mm"),
|
||||
duration: 60,
|
||||
maxJourneys: 10,
|
||||
passlist: 1,
|
||||
language: "sv",
|
||||
format: "json"
|
||||
);
|
||||
|
||||
return result.ToContract();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using HomeApi.Integration.Client;
|
||||
using HomeApi.Integration.Client.WeatherClient;
|
||||
using HomeApi.Models.Configuration;
|
||||
using HomeApi.Models.Response;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
Reference in New Issue
Block a user