blob: 9894f14ed3c6856741f4a9d39457e22b72f9b9e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
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 feedsArg = args.Feeds.Length > 0
? $"(feeds: [{string.Join(", ", args.Feeds.Select(f => $"\"{f}\""))}])"
: "";
return $$"""
query Query {
routes{{feedsArg}} {
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; }
}
}
|