From a304c24b32c0327436bbd8c2853e60668e161b42 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero Date: Mon, 29 Dec 2025 00:41:52 +0100 Subject: Rename a lot of stuff, add Santiago real time --- .../CorunaRealtimeEstimatesProvider.cs | 50 ---------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/Costasdev.Busurbano.Sources.TranviasCoruna/CorunaRealtimeEstimatesProvider.cs (limited to 'src/Costasdev.Busurbano.Sources.TranviasCoruna/CorunaRealtimeEstimatesProvider.cs') diff --git a/src/Costasdev.Busurbano.Sources.TranviasCoruna/CorunaRealtimeEstimatesProvider.cs b/src/Costasdev.Busurbano.Sources.TranviasCoruna/CorunaRealtimeEstimatesProvider.cs deleted file mode 100644 index 4bc7ef1..0000000 --- a/src/Costasdev.Busurbano.Sources.TranviasCoruna/CorunaRealtimeEstimatesProvider.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Net.Http.Json; - -namespace Costasdev.Busurbano.Sources.TranviasCoruna; - -public class CorunaRealtimeEstimatesProvider -{ - private HttpClient _http; - - public CorunaRealtimeEstimatesProvider(HttpClient http) - { - _http = http; - } - - public async Task> GetEstimatesForStop(int stopId) - { - var url = GetRequestUrl(stopId.ToString()); - - var response = await _http.GetAsync(url); - var queryitrResponse = await response.Content.ReadFromJsonAsync(); - - if (queryitrResponse is null) - { - var responseString = await response.Content.ReadAsStringAsync(); - throw new Exception("Error parsing queryitr_v3 response: " + responseString); - } - - return queryitrResponse.ArrivalInfo.Routes.SelectMany(r => - { - return r.Arrivals.Select(arrival => - { - var minutes = arrival.Minutes == "<1" ? 0 : int.Parse(arrival.Minutes); - - return new CorunaEstimate - ( - r.RouteId.ToString(), - minutes, - int.Parse(arrival.Metres), - arrival.VehicleNumber.ToString() - ); - }).ToList(); - }).OrderBy(a => a.Minutes).ToList(); - } - - private string GetRequestUrl(string stopId) - { - return $"https://itranvias.com/queryitr_v3.php?&func=0&dato={stopId}"; - } -} - -public record CorunaEstimate(string RouteId, int Minutes, int Metres, string VehicleNumber); -- cgit v1.3