From ef86a09ee8d8fc287b382cf9092af8726b44ceae Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Mon, 17 Nov 2025 16:39:48 +0100 Subject: Drop support for Santiago de Compostela, add collection script --- .../Controllers/SantiagoController.cs | 72 ---------------------- 1 file changed, 72 deletions(-) delete mode 100644 src/Costasdev.Busurbano.Backend/Controllers/SantiagoController.cs (limited to 'src/Costasdev.Busurbano.Backend/Controllers/SantiagoController.cs') diff --git a/src/Costasdev.Busurbano.Backend/Controllers/SantiagoController.cs b/src/Costasdev.Busurbano.Backend/Controllers/SantiagoController.cs deleted file mode 100644 index 24ecab9..0000000 --- a/src/Costasdev.Busurbano.Backend/Controllers/SantiagoController.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Text.Json; -using Costasdev.VigoTransitApi.Types; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Caching.Memory; - -namespace Costasdev.Busurbano.Backend.Controllers; - -[ApiController] -[Route("api/santiago")] -public class SantiagoController : ControllerBase -{ - private readonly IMemoryCache _cache; - private readonly HttpClient _httpClient; - - public SantiagoController(HttpClient http, IMemoryCache cache) - { - _cache = cache; - _httpClient = http; - } - - [HttpGet("GetStopEstimates")] - public async Task Run() - { - var argumentAvailable = Request.Query.TryGetValue("id", out var requestedStopIdString); - if (!argumentAvailable) - { - return BadRequest("Please provide a stop id as a query parameter with the name 'id'."); - } - - var argumentNumber = int.TryParse(requestedStopIdString, out var requestedStopId); - if (!argumentNumber) - { - return BadRequest("The provided stop id is not a valid number."); - } - - try - { - var obj = await _httpClient.GetFromJsonAsync( - $"https://app.tussa.org/tussa/api/paradas/{requestedStopId}"); - - if (obj is null) - { - return BadRequest("No response returned from the API, or whatever"); - } - - var root = obj.RootElement; - - List estimates = root - .GetProperty("lineas") - .EnumerateArray() - .Select(el => new StopEstimate( - el.GetProperty("sinoptico").GetString() ?? string.Empty, - el.GetProperty("nombre").GetString() ?? string.Empty, - el.GetProperty("minutosProximoPaso").GetInt32(), - 0 - )).ToList(); - - // Return only the estimates array, not the stop metadata - return new OkObjectResult(estimates); - } - catch (InvalidOperationException) - { - return BadRequest("Stop not found"); - } - } - - [HttpGet("GetStopTimetable")] - public async Task GetStopTimetable() - { - throw new NotImplementedException(); - } -} -- cgit v1.3