java.lang.Object
com.cta4j.client.TrainClient
A client for interacting with the CTA Train Tracker API.
-
Constructor Summary
ConstructorsConstructorDescriptionTrainClient(String apiKey) Constructs a newTrainClientwith the default host and the specified API key.TrainClient(String host, String apiKey) Constructs a newTrainClientwith the specified host and API key. -
Method Summary
Modifier and TypeMethodDescriptiongetStationArrivals(String stationId) Retrieves aListof upcoming arrivals for a specific station.Retrieves information about a specific train by its run number.
-
Constructor Details
-
TrainClient
Constructs a newTrainClientwith the specified host and API key.- Parameters:
host- the host of the CTA Train Tracker APIapiKey- the API key for accessing the CTA Train Tracker API- Throws:
NullPointerException- if host or API key isnull
-
TrainClient
Constructs a newTrainClientwith the default host and the specified API key.- Parameters:
apiKey- the API key for accessing the CTA Train Tracker API- Throws:
NullPointerException- if API key isnull
-
-
Method Details
-
getStationArrivals
Retrieves aListof upcoming arrivals for a specific station.- Parameters:
stationId- the ID of the station- Returns:
- a
Listof upcoming arrivals for the specified station - Throws:
NullPointerException- if the specified station ID isnullCta4jException- if an error occurs while fetching the data
-
getTrain
Retrieves information about a specific train by its run number.- Parameters:
run- the run number of the train- Returns:
- an
Optionalcontaining the train information if found, or an emptyOptionalif not found - Throws:
NullPointerException- if the specified run number isnullCta4jException- if an error occurs while fetching the data
-