Documentation
¶
Index ¶
- type ArrivalBoard
- type ArrivalTrainService
- type BaseCallingPoint
- type BaseTrainService
- type BoardOptions
- type Client
- type DepartureBoard
- type DepartureBoardIOClient
- type DepartureTrainService
- type FakeClient
- type PreviousCallingPointsListElement
- type PreviousSubsequentCallingPoint
- type SubsequentCallingPointsListElement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrivalBoard ¶ added in v0.1.7
type ArrivalBoard struct {
TrainServices []ArrivalTrainService `json:"trainServices,omitempty"`
}
ArrivalBoard models the useful elements of a departureboard.io response to a query for arrival board.
type ArrivalTrainService ¶ added in v0.1.7
type ArrivalTrainService struct { BaseTrainService // STA is the Scheduled Time of Arrival. It is a 24 hour time as a string. STA string `json:"sta,omitempty"` // ETA is the Estimated Time of Arrival. If the ETA is equal to the STA, then the ETA is 'On time', otherwise it is a 24 hour time as a string. ETA string `json:"eta,omitempty"` // PreviousCallingPointsList is an array of one element 'previousCallingPoints'. PreviousCallingPointsList []PreviousCallingPointsListElement `json:"previousCallingPointsList,omitempty"` }
ArrivalTrainService is a model of a National Rail train service on a arrival board.
type BaseCallingPoint ¶ added in v0.1.7
type BaseCallingPoint struct { // Location name associated calling point. LocationName string `json:"locationName,omitempty"` // CRS is the Computer Reservation System, three letter name for the calling point. CRS string `json:"crs"` }
BaseCallingPoint models the common structure in all calling points returned by the departureboard.io API.
type BaseTrainService ¶ added in v0.1.7
type BaseTrainService struct { // Origin is an array of calling points I think it is only ever one element long and contains the stop from which the train started its journey. Origin []BaseCallingPoint `json:"origin,omitempty"` // Destination is an array of calling points but I think it is only ever one element long and contains the stop from which the train will end its journey. Destination []BaseCallingPoint `json:"destination,omitempty"` // Platform is the platform on which the train will stop at for the queried station. Platform string `json:"platform,omitempty"` }
BaseTrainService models the common structure of the train services returned by the departureboard.io API.
type BoardOptions ¶ added in v0.1.7
type BoardOptions struct { // The number of departing services to return. // This is a maximum value, less may be returned if there is not a sufficient amount of services running from the selected station within the time window specified. NumServices int // The time window in minutes to offset the departure information by. // For example, a value of 20 will not show services departing within the next 20 minutes. TimeOffset int // The time window to show services for in minutes. // For example, a value of 60 will show services departing the station in the next 60 minutes. TimeWindow int // Should the response contain information on the calling points for each service? // If set to false, calling points will not be returned. ServiceDetails bool // The CRS (Computer Reservation System) code to filter the results by. // For example, performing a lookup for PAD (London Paddington) and setting filterStation to RED (Reading), will only show services departing from Paddington that stop at Reading. FilterStation *string }
BoardOptions are query parameters that can be set on requests for station arrival or departure boards.
func NewBoardOptions ¶
func NewBoardOptions(numServices, timeOffset, timeWindow int, serviceDetails bool, filterStation *string) (BoardOptions, error)
NewBoardOptions returns BoardOptions for the provided values. It does not do any validation of its arguments but returns an error in case validation is implemented.
func NewDefaultBoardOptions ¶
func NewDefaultBoardOptions() BoardOptions
NewDefaultBoardOptions returns sensible default options for a Board query.
type Client ¶
Client implements the DepartureBoardIOClient interface by making HTTP requests of the api.departureboard.io JSON API.
func (Client) GetArrivalsByCRS ¶
func (c Client) GetArrivalsByCRS(apiEndpoint, apiKey, crs string, options BoardOptions) (*ArrivalBoard, error)
GetArrivalsByCRS returns a Board of the results from the getDeparturesByCRS endpoint.
func (Client) GetDeparturesByCRS ¶
func (c Client) GetDeparturesByCRS(apiEndpoint, apiKey, crs string, options BoardOptions) (*DepartureBoard, error)
GetDeparturesByCRS returns a Board of the results from the getDeparturesByCRS endpoint.
type DepartureBoard ¶ added in v0.1.7
type DepartureBoard struct {
TrainServices []DepartureTrainService `json:"trainServices,omitempty"`
}
DepartureBoard models the useful elements of a departureboard.io response to a query for departure board.
type DepartureBoardIOClient ¶ added in v0.1.7
type DepartureBoardIOClient interface { GetDeparturesByCRS(apiEndpoint, apiKey, crs string, oardOptions BoardOptions) (*DepartureBoard, error) GetArrivalsByCRS(apiEndpoint, apiKey, crs string, boardOptions BoardOptions) (*ArrivalBoard, error) }
type DepartureTrainService ¶ added in v0.1.7
type DepartureTrainService struct { BaseTrainService // STD is the Scheduled Time of Departure. It is a 24 hour time as a string. STD string `json:"std,omitempty"` // ETA is the Estimated Time of Departure. If the ETD is equal to the STD, then the ETD is 'On time', otherwise it is a 24 hour time as a string. ETD string `json:"etd,omitempty"` // SubsequentCallingPointsList contains arrays of all future calling points. // Usually this array is only one element long but can be longer if a service splits. SubsequentCallingPointsList []SubsequentCallingPointsListElement `json:"subsequentCallingPointsList,omitempty"` }
DepartureTrainService is a model of a National Rail train service on a departure board.
type FakeClient ¶ added in v0.1.7
type FakeClient struct { APIEndpoint url.URL APIKey string Arrivals map[string][]ArrivalTrainService Departures map[string][]DepartureTrainService }
FakeClient is an in memory fake that implements the DepartureBoardIOClient interface.
func NewFakeClient ¶ added in v0.1.7
func NewFakeClient(crsCodes []string) *FakeClient
NewFakeClient returns a new FakeClient with arrivals and departure train services generated for all provided crsCodes.
func (FakeClient) GetArrivalsByCRS ¶ added in v0.1.7
func (fc FakeClient) GetArrivalsByCRS(apiKey, apiEndpoint, crs string, boardOptions BoardOptions) (*ArrivalBoard, error)
func (FakeClient) GetDeparturesByCRS ¶ added in v0.1.7
func (fc FakeClient) GetDeparturesByCRS(apiKey, apiEndpoint, crs string, boardOptions BoardOptions) (*DepartureBoard, error)
type PreviousCallingPointsListElement ¶ added in v0.1.5
type PreviousCallingPointsListElement struct { // PreviousCallingPoints contains all scheduled calling points in order from origin to destination including the origin and destination themselves. PreviousCallingPoints []PreviousSubsequentCallingPoint `json:"previousCallingPoints,omitempty"` }
type PreviousSubsequentCallingPoint ¶ added in v0.1.7
type PreviousSubsequentCallingPoint struct { BaseCallingPoint // ST is the Scheduled Time that a service is to be at the calling point. ST string `json:"st"` // ET is the Estimated Time that a service is to be at a calling point. // If the ET is equal to the ST, then the ET 'On time', otherwise it is a 24 hour time as a string. ET string `json:"et"` }
PreviousSubsequentCallingPoint has extra fields that are only present in previous or subsequent calling points and not in the origin or destination calling points where that information is part of the train service.
type SubsequentCallingPointsListElement ¶ added in v0.1.5
type SubsequentCallingPointsListElement struct { // SubsequentCallingPoints contains all future calling points. SubsequentCallingPoints []PreviousSubsequentCallingPoint `json:"subsequentCallingPoints,omitempty"` }