PythonRMV/pyrmv/methods/journey_detail.py

39 lines
1.1 KiB
Python
Raw Normal View History

2022-10-06 12:36:08 +03:00
from datetime import datetime
from typing import Union
from pyrmv.classes.Journey import Journey
2022-10-05 14:08:27 +03:00
from pyrmv.errors.not_ready import NotReadyYetError
2022-10-06 12:36:08 +03:00
from pyrmv.enums.rt_mode import RealTimeMode
from pyrmv.raw.journey_detail import journey_detail as raw_journey_detail
from pyrmv.utility.find_exception import find_exception
2022-10-05 14:08:27 +03:00
2022-10-06 12:36:08 +03:00
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
2022-10-05 14:08:27 +03:00
2022-10-06 12:36:08 +03:00
def journey_detail(
access_id: str,
id: str,
date: Union[str, datetime] = None,
real_time_mode: Literal[RealTimeMode.FULL, RealTimeMode.INFOS, RealTimeMode.OFF, RealTimeMode.REALTIME, RealTimeMode.SERVER_DEFAULT] = None,
from_id: str = None,
from_index: int = None,
to_id: str = None,
to_index: int = None
):
journey_raw = raw_journey_detail(
accessId=access_id,
id=id,
date=date,
rtMode=real_time_mode.code,
fromId=from_id,
fromIdx=from_index,
toId=to_id,
toIdx=to_index
)
find_exception(journey_raw)
return Journey(journey_raw)