Class: Ldbws::Service
- Inherits:
-
Object
- Object
- Ldbws::Service
- Defined in:
- lib/ldbws/service.rb
Overview
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.
Constant Summary collapse
- SERVICE_URI =
:nodoc:
URI("https://realtime.nationalrail.co.uk/OpenLDBWS/ldb12.asmx")
Instance Method Summary collapse
-
#get_arr_board_with_details(params) ⇒ Object
(also: #get_arrival_board_with_details)
Retrieves a detailed station arrival board.
-
#get_arr_dep_board_with_details(params) ⇒ Object
(also: #get_arrival_departure_board_with_details)
Retrieves a detailed station arrival + departures board.
-
#get_arrival_board(params) ⇒ Object
Retrieves a station arrival board.
-
#get_arrival_departure_board(params) ⇒ Object
Retrieves a station arrival + departure board.
-
#get_dep_board_with_details(params) ⇒ Object
(also: #get_departure_board_with_details)
Retrieves a detailed station departure board.
-
#get_departure_board(params) ⇒ Object
Retrieves a station departure board.
-
#get_fastest_departures(params) ⇒ Object
Retrieves the fastest departures from one station to one or many others.
-
#get_fastest_departures_with_details(params) ⇒ Object
Retrieves detailed information about the fastest departures from one station to one or many others.
-
#get_next_departures(params) ⇒ Object
Retrieves the next departures from one station to one or many others.
-
#get_next_departures_with_details(params) ⇒ Object
Retrieves detailed information about the next departures from one station to one or many others.
-
#get_service_details(params) ⇒ Object
Retrieves information about a specific service.
-
#initialize(token) ⇒ Service
constructor
Creates a service object.
Constructor Details
#initialize(token) ⇒ Service
Creates a service object.
Parameters
- token
-
the API token used to connect to the service
39 40 41 |
# File 'lib/ldbws/service.rb', line 39 def initialize(token) @token = token end |
Instance Method Details
#get_arr_board_with_details(params) ⇒ Object Also known as: get_arrival_board_with_details
Retrieves a detailed station arrival board.
Parameters are validated using GetStationBoardWithDetails, returns a StationBoardWithDetails object.
91 92 93 94 95 96 |
# 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) ⇒ Object Also known as: get_arrival_departure_board_with_details
Retrieves a detailed station arrival + departures board.
Parameters are validated using GetStationBoardWithDetails, returns a StationBoardWithDetails object.
102 103 104 105 106 107 |
# 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) ⇒ Object
Retrieves a station arrival board.
Parameters are validated using GetStationBoard, returns a StationBoard object.
58 59 60 61 62 63 |
# 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_departure_board(params) ⇒ Object
Retrieves a station arrival + departure board.
Parameters are validated using GetStationBoard, returns a StationBoard object.
69 70 71 72 73 74 |
# 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_dep_board_with_details(params) ⇒ Object Also known as: get_departure_board_with_details
Retrieves a detailed station departure board.
Parameters are validated using GetStationBoardWithDetails, returns a StationBoardWithDetails object.
80 81 82 83 84 85 |
# 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) ⇒ Object
Retrieves a station departure board.
Parameters are validated using GetStationBoard, returns a StationBoard object.
47 48 49 50 51 52 |
# 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_fastest_departures(params) ⇒ Object
Retrieves the fastest departures from one station to one or many others.
Parameters are validated using GetDeparturesBoard, returns a DeparturesBoard object.
124 125 126 127 128 129 |
# 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) ⇒ Object
Retrieves detailed information about the fastest departures from one station to one or many others.
Parameters are validated using GetDeparturesBoardWithDetails, returns a DeparturesBoardWithDetails object.
146 147 148 149 150 151 |
# 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) ⇒ Object
Retrieves the next departures from one station to one or many others.
Parameters are validated using GetDeparturesBoard, returns a DeparturesBoard object.
113 114 115 116 117 118 |
# 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) ⇒ Object
Retrieves detailed information about the next departures from one station to one or many others.
Parameters are validated using GetDeparturesBoardWithDetails, returns a DeparturesBoardWithDetails object.
135 136 137 138 139 140 |
# 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) ⇒ Object
Retrieves information about a specific service.
Parameters are validated using GetServiceDetails, returns a ServiceDetails object.
157 158 159 160 161 162 |
# 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 |