Skip to content

Commit

Permalink
Add Via and Vias data classes to represent via stations in train conn…
Browse files Browse the repository at this point in the history
…ections
  • Loading branch information
tjorim committed Jan 8, 2025
1 parent 79c8482 commit 06c6710
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion pyrail/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from typing import List, Optional
from typing import List

from mashumaro import field_options
from mashumaro.mixins.orjson import DataClassORJSONMixin
Expand Down Expand Up @@ -217,6 +217,28 @@ class ConnectionArrival(DataClassORJSONMixin):
departure_connection: str = field(metadata=field_options(alias="departureConnection")) # Departure connection link


@dataclass
class Via(DataClassORJSONMixin):
"""Represents a single via station in a train connection."""

id: str # Via ID
arrival: ConnectionArrival
departure: ConnectionDeparture
timebetween: int # Time between arrival and departure (assuming in seconds)
station: str # Station name
station_info: StationDetails = field(metadata=field_options(alias="stationinfo")) # Detailed station info
vehicle: str # Vehicle identifier
vehicle_info: VehicleInfo = field(metadata=field_options(alias="vehicleinfo")) # Vehicle details


@dataclass
class Vias(DataClassORJSONMixin):
"""Holds the number of vias and a list of detailed via information for connections."""

number: int # Number of vias
via: List[Via] = field(default_factory=list) # List of via details


@dataclass
class Remark(DataClassORJSONMixin):
"""Represents a single remark for a train connection, including type and content."""
Expand Down Expand Up @@ -268,6 +290,7 @@ class ConnectionDetails(DataClassORJSONMixin):
duration: int # Duration of the connection in minutes
remarks: Remarks # Remarks for the connection
alerts: Alerts # Alerts for the connection
vias: Vias | None = field(default=None) # Vias information


@dataclass
Expand Down

0 comments on commit 06c6710

Please sign in to comment.