Class BusClient

java.lang.Object
com.cta4j.client.BusClient

public final class BusClient extends Object
A client for interacting with the CTA Bus Tracker API.
  • Constructor Details

    • BusClient

      public BusClient(String host, String apiKey)
      Constructs a new BusClient with the specified host and API key.
      Parameters:
      host - the host of the CTA Bus Tracker API
      apiKey - the API key for accessing the CTA Bus Tracker API
      Throws:
      NullPointerException - if the specified host or API key is null
    • BusClient

      public BusClient(String apiKey)
      Constructs a new BusClient with the default host and the specified API key.
      Parameters:
      apiKey - the API key for accessing the CTA Bus Tracker API
      Throws:
      NullPointerException - if API key is null
  • Method Details

    • getRoutes

      public List<Route> getRoutes()
      Retrieves a List of all bus routes.
      Returns:
      a List of all bus routes
      Throws:
      Cta4jException - if an error occurs while fetching the data
    • getDirections

      public List<String> getDirections(String routeId)
      Retrieves a List of directions for a specific bus route.
      Parameters:
      routeId - the ID of the bus route
      Returns:
      a List of directions for the specified bus route
      Throws:
      NullPointerException - if the specified bus route is null
      Cta4jException - if an error occurs while fetching the data
    • getStops

      public List<Stop> getStops(String routeId, String direction)
      Retrieves a List of stops for a specific bus route and direction.
      Parameters:
      routeId - the ID of the bus route
      direction - the direction of the bus route
      Returns:
      a List of stops for the specified bus route and direction
      Throws:
      NullPointerException - if the specified bus route or direction is null
      Cta4jException - if an error occurs while fetching the data
    • getStopArrivals

      public List<StopArrival> getStopArrivals(String routeId, String stopId)
      Retrieves a List of upcoming arrivals for a specific bus route and stop.
      Parameters:
      routeId - the ID of the bus route
      stopId - the ID of the bus stop
      Returns:
      a List of upcoming arrivals for the specified bus route and stop
      Throws:
      NullPointerException - if the specified bus route or stop is null
      Cta4jException - if an error occurs while fetching the data
    • getDetours

      public List<Detour> getDetours(String routeId, String direction)
      Retrieves a List of detours for a specific bus route and direction.
      Parameters:
      routeId - the ID of the bus route
      direction - the direction of the bus route
      Returns:
      a List of detours for the specified bus route and direction
      Throws:
      NullPointerException - if the specified bus route or direction is null
      Cta4jException - if an error occurs while fetching the data
    • getBus

      public Optional<Bus> getBus(String id)
      Retrieves information about a specific bus by its ID.
      Parameters:
      id - the ID of the bus
      Returns:
      an Optional containing the bus information if found, or an empty Optional if not found
      Throws:
      NullPointerException - if the specified bus ID is null
      Cta4jException - if an error occurs while fetching the data