diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-28 18:21:17 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-28 18:21:30 +0100 |
| commit | b2ddc0ef449ccbe7f0d33e539ccdfc1baef04e2c (patch) | |
| tree | e097f7e990a610762d8c4297f82147c57b4635fd /src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries | |
| parent | 4fb2fe683b75464917dec4b1a0aaee63830f3b9a (diff) | |
Get favourite stops from OTP instead of pre-generated file
Diffstat (limited to 'src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries')
| -rw-r--r-- | src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopsInfo.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopsInfo.cs b/src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopsInfo.cs new file mode 100644 index 0000000..ce6a8c7 --- /dev/null +++ b/src/Costasdev.Busurbano.Sources.OpenTripPlannerGql/Queries/StopsInfo.cs @@ -0,0 +1,57 @@ +using System.Globalization; +using System.Text.Json.Serialization; + +namespace Costasdev.Busurbano.Sources.OpenTripPlannerGql.Queries; + +public class StopsInfoContent : IGraphRequest<StopsInfoContent.Args> +{ + public record Args(IEnumerable<string> Ids); + + public static string Query(Args args) + { + var idsString = string.Join("\",\"", args.Ids); + return string.Create(CultureInfo.InvariantCulture, $@" + query Query {{ + stops(ids: [""{idsString}""]) {{ + gtfsId + code + name + lat + lon + routes {{ + shortName + color + textColor + }} + }} + }} + "); + } +} + +public class StopsInfoResponse : AbstractGraphResponse +{ + [JsonPropertyName("stops")] public List<StopItem>? Stops { get; set; } + + public class StopItem + { + [JsonPropertyName("gtfsId")] public required string GtfsId { get; set; } + + [JsonPropertyName("code")] public string? Code { get; set; } + + [JsonPropertyName("name")] public required string Name { get; set; } + + [JsonPropertyName("lat")] public double Lat { get; set; } + + [JsonPropertyName("lon")] public double Lon { get; set; } + + [JsonPropertyName("routes")] public List<RouteDetails> Routes { get; set; } = []; + } + + public class RouteDetails + { + [JsonPropertyName("shortName")] public string? ShortName { get; set; } + [JsonPropertyName("color")] public string? Color { get; set; } + [JsonPropertyName("textColor")] public string? TextColor { get; set; } + } +} |
