Documentation
¶
Index ¶
Constants ¶
const (
APIBase = "https://transport.opendata.ch/v1/connections"
)
APIBase Information about the OpenTransport API
Variables ¶
var RequiredFields = []string{
"connections/from/station/name",
"connections/from/departure",
"connections/from/platform",
"connections/to/station/name",
"connections/to/arrival",
"connections/duration",
}
RequiredFields from the transport APi
Functions ¶
func PrintConnectionList ¶
func PrintConnectionList(connections []Connection)
PrintConnectionList prints out a list of connections
Types ¶
type Checkpoint ¶
Checkpoint represents an arrival or a departure point (in time and space) of a connection
type Connection ¶
type Connection struct {
From Checkpoint
To Checkpoint
Duration string
}
Connection represents a possible journey between two locations
func (*Connection) DisplayArrival ¶
func (c *Connection) DisplayArrival() string
DisplayArrival returns the formatted starting Location
func (*Connection) DisplayDeparture ¶
func (c *Connection) DisplayDeparture() string
DisplayDeparture returns the formatted starting Location
func (*Connection) DisplayDuration ¶
func (c *Connection) DisplayDuration() string
DisplayDuration returns the formatted starting Location
func (*Connection) DisplayFrom ¶
func (c *Connection) DisplayFrom() string
DisplayFrom returns the formatted starting Location
func (*Connection) DisplayTo ¶
func (c *Connection) DisplayTo() string
DisplayTo returns the formatted starting Location
type Location ¶
type Location struct {
Name string
}
Location represents a Checkpoint on a Connection
type Query ¶
Query represents a timetable enquiry
func ParseQuery ¶
ParseQuery tries to interpret user input into a query
type Response ¶
type Response struct {
Connections []Connection
}
Response represents the root object of a OpenTransport API response
func FetchConnections ¶
FetchConnections queries the OpenTransport API