diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-22 14:13:45 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-22 14:13:53 +0100 |
| commit | 91f7d7dd5a4ca8453cfdbc9a3beeb216b6638ef7 (patch) | |
| tree | f9d036a5b692aa10bb61b7a8ccc30c58f29a79f2 /src/Costasdev.Busurbano.Backend/GraphClient/App | |
| parent | 4e583cc587f9b8cc159cedeb63af2f38d5451507 (diff) | |
Implement fetching scheduled arrivals for stop
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/GraphClient/App')
| -rw-r--r-- | src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs b/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs new file mode 100644 index 0000000..dfecdd6 --- /dev/null +++ b/src/Costasdev.Busurbano.Backend/GraphClient/App/ArrivalsAtStop.cs @@ -0,0 +1,82 @@ +using System.Globalization; +using System.Text.Json.Serialization; + +namespace Costasdev.Busurbano.Backend.GraphClient.App; + +public class ArrivalsAtStopContent : IGraphRequest<string> +{ + public static string Query(string id) + { + return string.Create(CultureInfo.InvariantCulture, $@" + query Query {{ + stop(id:""{id}"") {{ + code + name + arrivals: stoptimesWithoutPatterns(numberOfDepartures:10) {{ + trip {{ + gtfsId + routeShortName + route {{ + color + textColor + }} + }} + headsign + scheduledDeparture + }} + }} + }} + "); + } +} + +public class ArrivalsAtStopResponse : AbstractGraphResponse +{ + [JsonPropertyName("stop")] + public StopItem Stop { get; set; } + + public class StopItem + { + [JsonPropertyName("code")] + public required string Code { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("arrivals")] + public List<Arrival> Arrivals { get; set; } = []; + } + + public class Arrival + { + [JsonPropertyName("headsign")] + public required string Headsign { get; set; } + + [JsonPropertyName("scheduledDeparture")] + public int ScheduledDepartureSeconds { get; set; } + + [JsonPropertyName("trip")] + public required TripDetails Trip { get; set; } + } + + public class TripDetails + { + [JsonPropertyName("gtfsId")] + public required string GtfsId { get; set; } + + [JsonPropertyName("routeShortName")] + public required string RouteShortName { get; set; } + + [JsonPropertyName("route")] + public required RouteDetails Route { get; set; } + } + + public class RouteDetails + { + [JsonPropertyName("color")] + public required string Color { get; set; } + + [JsonPropertyName("textColor")] + public required string TextColor { get; set; } + } +} |
