diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-29 00:41:52 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-29 00:41:52 +0100 |
| commit | a304c24b32c0327436bbd8c2853e60668e161b42 (patch) | |
| tree | 08f65c05daca134cf4d2e4f779bd15d98fd66370 /src/Enmarcha.Sources.OpenTripPlannerGql/Queries/RoutesListContent.cs | |
| parent | 120a3c6bddd0fb8d9fa05df4763596956554c025 (diff) | |
Rename a lot of stuff, add Santiago real time
Diffstat (limited to 'src/Enmarcha.Sources.OpenTripPlannerGql/Queries/RoutesListContent.cs')
| -rw-r--r-- | src/Enmarcha.Sources.OpenTripPlannerGql/Queries/RoutesListContent.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/RoutesListContent.cs b/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/RoutesListContent.cs new file mode 100644 index 0000000..71360ee --- /dev/null +++ b/src/Enmarcha.Sources.OpenTripPlannerGql/Queries/RoutesListContent.cs @@ -0,0 +1,66 @@ +using System.Globalization; +using System.Text.Json.Serialization; + +namespace Enmarcha.Sources.OpenTripPlannerGql.Queries; + +public class RoutesListContent : IGraphRequest<RoutesListContent.Args> +{ + public record Args(string[] Feeds, string ServiceDate); + + public static string Query(Args args) + { + var feedsStr = string.Join(", ", args.Feeds.Select(f => $"\"{f}\"")); + return string.Create(CultureInfo.InvariantCulture, $$""" + query Query { + routes(feeds: [{{feedsStr}}]) { + gtfsId + shortName + longName + color + textColor + sortOrder + agency { + name + } + patterns { + tripsForDate(serviceDate: "{{args.ServiceDate}}") { + id + } + } + } + } + """); + } +} + +public class RoutesListResponse : AbstractGraphResponse +{ + [JsonPropertyName("routes")] public List<RouteItem> Routes { get; set; } = []; + + public class RouteItem + { + [JsonPropertyName("gtfsId")] public required string GtfsId { get; set; } + [JsonPropertyName("shortName")] public string? ShortName { get; set; } + [JsonPropertyName("longName")] public string? LongName { get; set; } + [JsonPropertyName("color")] public string? Color { get; set; } + [JsonPropertyName("textColor")] public string? TextColor { get; set; } + [JsonPropertyName("sortOrder")] public int? SortOrder { get; set; } + [JsonPropertyName("agency")] public AgencyItem? Agency { get; set; } + [JsonPropertyName("patterns")] public List<PatternItem> Patterns { get; set; } = []; + } + + public class AgencyItem + { + [JsonPropertyName("name")] public string? Name { get; set; } + } + + public class PatternItem + { + [JsonPropertyName("tripsForDate")] public List<TripItem> TripsForDate { get; set; } = []; + } + + public class TripItem + { + [JsonPropertyName("id")] public string? Id { get; set; } + } +} |
