Add national days API to calendar

This commit is contained in:
2024-12-19 11:03:40 -05:00
parent 532ee37169
commit edc4d13d85
11 changed files with 102 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
using ChrisKaczor.HomeMonitor.Calendar.Service.Models.NationalDays;
using Microsoft.AspNetCore.Mvc;
using RestSharp;
namespace ChrisKaczor.HomeMonitor.Calendar.Service.Controllers;
[Route("national-days")]
[ApiController]
public class NationalDaysController(IConfiguration configuration, RestClient restClient) : ControllerBase
{
[HttpGet("today")]
public async Task<ActionResult<Response>> GetToday()
{
var restRequest = new RestRequest(configuration["Calendar:NationalDays:Url"]);
restRequest.AddHeader("X-Api-Key", configuration["Calendar:NationalDays:Key"] ?? string.Empty);
var response = await restClient.GetAsync<Response>(restRequest);
return Ok(response?.Data.Where(d => d.Type == "day"));
}
}