diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-31 14:38:29 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-31 14:38:29 +0100 |
| commit | 5614fbc76c59a8c0bfe5cafc9af4805e43351c1c (patch) | |
| tree | ea6c627ea530849433ff48c5de0516d60c7fbe77 /src/Enmarcha.Backend/Types | |
| parent | fca243af88be3081dc036eaf50ea8f409ad9e9d0 (diff) | |
feat: Add vehicle information to arrival details and update related components
Diffstat (limited to 'src/Enmarcha.Backend/Types')
| -rw-r--r-- | src/Enmarcha.Backend/Types/Arrivals/Arrival.cs | 92 |
1 files changed, 43 insertions, 49 deletions
diff --git a/src/Enmarcha.Backend/Types/Arrivals/Arrival.cs b/src/Enmarcha.Backend/Types/Arrivals/Arrival.cs index e99baa7..9d2ea1b 100644 --- a/src/Enmarcha.Backend/Types/Arrivals/Arrival.cs +++ b/src/Enmarcha.Backend/Types/Arrivals/Arrival.cs @@ -1,106 +1,100 @@ using System.Text.Json.Serialization; using Enmarcha.Backend.Types; +using Newtonsoft.Json; namespace Enmarcha.Backend.Types.Arrivals; public class Arrival { - [JsonPropertyName("tripId")] - public required string TripId { get; set; } + [JsonPropertyName("tripId")] public required string TripId { get; set; } - [JsonPropertyName("route")] - public required RouteInfo Route { get; set; } + [JsonPropertyName("route")] public required RouteInfo Route { get; set; } - [JsonPropertyName("headsign")] - public required HeadsignInfo Headsign { get; set; } + [JsonPropertyName("headsign")] public required HeadsignInfo Headsign { get; set; } - [JsonPropertyName("estimate")] - public required ArrivalDetails Estimate { get; set; } + [JsonPropertyName("estimate")] public required ArrivalDetails Estimate { get; set; } - [JsonPropertyName("delay")] - public DelayBadge? Delay { get; set; } + [JsonPropertyName("delay")] public DelayBadge? Delay { get; set; } - [JsonPropertyName("shift")] - public ShiftBadge? Shift { get; set; } + [JsonPropertyName("shift")] public ShiftBadge? Shift { get; set; } - [JsonPropertyName("shape")] - public object? Shape { get; set; } + [JsonPropertyName("shape")] public object? Shape { get; set; } - [JsonPropertyName("currentPosition")] - public Position? CurrentPosition { get; set; } + [JsonPropertyName("currentPosition")] public Position? CurrentPosition { get; set; } - [JsonPropertyName("stopShapeIndex")] - public int? StopShapeIndex { get; set; } + [JsonPropertyName("stopShapeIndex")] public int? StopShapeIndex { get; set; } - [JsonIgnore] + [JsonPropertyName("vehicleInformation")] + public VehicleBadge? VehicleInformation { get; set; } + + [System.Text.Json.Serialization.JsonIgnore] public List<string> NextStops { get; set; } = []; - [JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public object? RawOtpTrip { get; set; } } public class RouteInfo { - [JsonPropertyName("gtfsId")] - public required string GtfsId { get; set; } + [JsonPropertyName("gtfsId")] public required string GtfsId { get; set; } public string RouteIdInGtfs => GtfsId.Split(':', 2)[1]; - [JsonPropertyName("shortName")] - public required string ShortName { get; set; } + [JsonPropertyName("shortName")] public required string ShortName { get; set; } - [JsonPropertyName("colour")] - public required string Colour { get; set; } + [JsonPropertyName("colour")] public required string Colour { get; set; } - [JsonPropertyName("textColour")] - public required string TextColour { get; set; } + [JsonPropertyName("textColour")] public required string TextColour { get; set; } } public class HeadsignInfo { - [JsonPropertyName("badge")] - public string? Badge { get; set; } + [JsonPropertyName("badge")] public string? Badge { get; set; } - [JsonPropertyName("destination")] - public required string Destination { get; set; } + [JsonPropertyName("destination")] public required string Destination { get; set; } - [JsonPropertyName("marquee")] - public string? Marquee { get; set; } + [JsonPropertyName("marquee")] public string? Marquee { get; set; } } public class ArrivalDetails { - [JsonPropertyName("minutes")] - public required int Minutes { get; set; } + [JsonPropertyName("minutes")] public required int Minutes { get; set; } - [JsonPropertyName("precision")] - public ArrivalPrecision Precision { get; set; } = ArrivalPrecision.Scheduled; + [JsonPropertyName("precision")] public ArrivalPrecision Precision { get; set; } = ArrivalPrecision.Scheduled; } -[JsonConverter(typeof(JsonStringEnumConverter))] +[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))] public enum ArrivalPrecision { [JsonStringEnumMemberName("confident")] Confident = 0, - [JsonStringEnumMemberName("unsure")] - Unsure = 1, + [JsonStringEnumMemberName("unsure")] Unsure = 1, + [JsonStringEnumMemberName("scheduled")] Scheduled = 2, - [JsonStringEnumMemberName("past")] - Past = 3 + [JsonStringEnumMemberName("past")] Past = 3 } public class DelayBadge { - [JsonPropertyName("minutes")] - public int Minutes { get; set; } + [JsonPropertyName("minutes")] public int Minutes { get; set; } } public class ShiftBadge { - [JsonPropertyName("shiftName")] - public required string ShiftName { get; set; } + [JsonPropertyName("shiftName")] public required string ShiftName { get; set; } + + [JsonPropertyName("shiftTrip")] public required string ShiftTrip { get; set; } +} + +public class VehicleBadge +{ + [JsonPropertyName("identifier")] public required string Identifier { get; set; } + + [JsonPropertyName("make")] public string? Make { get; set; } + [JsonPropertyName("model")] public string? Model { get; set; } + [JsonPropertyName("kind")] public string? Kind { get; set; } + [JsonPropertyName("year")] public string? Year { get; set; } + - [JsonPropertyName("shiftTrip")] - public required string ShiftTrip { get; set; } } |
