class Ldbws::Service

A wrapper around the National Rail Live Departure Boards Webservice (LDBWS) API.

API methods are pretty much as-specified in the documentation, although methods on this class are specified using snake_case rather than the CamelCase used in the web service.

Usage example

TL;DR:

service = new Ldbws::Service( "YOUR-API-TOKEN" )
departures = service.get_departure_board( crs: "CDF" )

Will furnish you with a list of all departures from Cardiff Central. Other methods work pretty much as you’d expect if you’ve any familiarity with the service. Individual requests use Request objects to validate input parameters, and this is noted below. See the corresponding request object for each method for further information as to the parameters.

Side note

The official documentation for this web service is… lacking. While an attempt has been made to elucidate on both the request parameters and response properties, it shouldn’t be taken as any kind of source of truth. Caveat emptor.

Public Class Methods

new(token) click to toggle source

Creates a service object.

Parameters

token

the API token used to connect to the service

# File lib/ldbws/service.rb, line 39
def initialize(token)
  @token = token
end

Public Instance Methods

get_arr_board_with_details(params) click to toggle source

Retrieves a detailed station arrival board.

Parameters are validated using GetStationBoardWithDetails, returns a StationBoardWithDetails object.

# File lib/ldbws/service.rb, line 91
def get_arr_board_with_details(params)
  request(
    "http://thalesgroup.com/RTTI/2015-05-14/ldb/GetArrBoardWithDetails",
    Request::GetStationBoardWithDetails.new(params)
  )
end
get_arr_dep_board_with_details(params) click to toggle source

Retrieves a detailed station arrival + departures board.

Parameters are validated using GetStationBoardWithDetails, returns a StationBoardWithDetails object.

# File lib/ldbws/service.rb, line 102
def get_arr_dep_board_with_details(params)
  request(
    "http://thalesgroup.com/RTTI/2015-05-14/ldb/GetArrDepBoardWithDetails",
    Request::GetStationBoardWithDetails.new(params)
  )
end
get_arrival_board(params) click to toggle source

Retrieves a station arrival board.

Parameters are validated using GetStationBoard, returns a StationBoard object.

# File lib/ldbws/service.rb, line 58
def get_arrival_board(params)
  request(
    "http://thalesgroup.com/RTTI/2012-01-13/ldb/GetArrivalBoard",
    Request::GetStationBoard.new(params)
  )
end
get_arrival_board_with_details(params)
get_arrival_departure_board(params) click to toggle source

Retrieves a station arrival + departure board.

Parameters are validated using GetStationBoard, returns a StationBoard object.

# File lib/ldbws/service.rb, line 69
def get_arrival_departure_board(params)
  request(
    "http://thalesgroup.com/RTTI/2012-01-13/ldb/GetArrivalDepartureBoard",
    Request::GetStationBoard.new(params)
  )
end
get_arrival_departure_board_with_details(params)
get_dep_board_with_details(params) click to toggle source

Retrieves a detailed station departure board.

Parameters are validated using GetStationBoardWithDetails, returns a StationBoardWithDetails object.

# File lib/ldbws/service.rb, line 80
def get_dep_board_with_details(params)
  request(
    "http://thalesgroup.com/RTTI/2015-05-14/ldb/GetDepBoardWithDetails",
    Request::GetStationBoardWithDetails.new(params)
  )
end
get_departure_board(params) click to toggle source

Retrieves a station departure board.

Parameters are validated using GetStationBoard, returns a StationBoard object.

# File lib/ldbws/service.rb, line 47
def get_departure_board(params)
  request(
    "http://thalesgroup.com/RTTI/2012-01-13/ldb/GetDepartureBoard",
    Request::GetStationBoard.new(params)
  )
end
get_departure_board_with_details(params)
get_fastest_departures(params) click to toggle source

Retrieves the fastest departures from one station to one or many others.

Parameters are validated using GetDeparturesBoard, returns a DeparturesBoard object.

# File lib/ldbws/service.rb, line 124
def get_fastest_departures(params)
  request(
    "http://thalesgroup.com/RTTI/2015-05-14/ldb/GetFastestDepartures",
    Request::GetDeparturesBoard.new(params)
  )
end
get_fastest_departures_with_details(params) click to toggle source

Retrieves detailed information about the fastest departures from one station to one or many others.

Parameters are validated using GetDeparturesBoardWithDetails, returns a DeparturesBoardWithDetails object.

# File lib/ldbws/service.rb, line 146
def get_fastest_departures_with_details(params)
  request(
    "http://thalesgroup.com/RTTI/2015-05-14/ldb/GetFastestDeparturesWithDetails",
    Request::GetDeparturesBoardWithDetails.new(params)
  )
end
get_next_departures(params) click to toggle source

Retrieves the next departures from one station to one or many others.

Parameters are validated using GetDeparturesBoard, returns a DeparturesBoard object.

# File lib/ldbws/service.rb, line 113
def get_next_departures(params)
  request(
    "http://thalesgroup.com/RTTI/2015-05-14/ldb/GetNextDepartures",
    Request::GetDeparturesBoard.new(params)
  )
end
get_next_departures_with_details(params) click to toggle source

Retrieves detailed information about the next departures from one station to one or many others.

Parameters are validated using GetDeparturesBoardWithDetails, returns a DeparturesBoardWithDetails object.

# File lib/ldbws/service.rb, line 135
def get_next_departures_with_details(params)
  request(
    "http://thalesgroup.com/RTTI/2015-05-14/ldb/GetNextDeparturesWithDetails",
    Request::GetDeparturesBoardWithDetails.new(params)
  )
end
get_service_details(params) click to toggle source

Retrieves information about a specific service.

Parameters are validated using GetServiceDetails, returns a ServiceDetails object.

# File lib/ldbws/service.rb, line 157
def get_service_details(params)
  request(
    "http://thalesgroup.com/RTTI/2012-01-13/ldb/GetServiceDetails",
    Request::GetServiceDetails.new(params)
  )
end