Documentation
¶
Index ¶
- Constants
- type Api
- type DmvApi
- func (dmv *DmvApi) FetchPredictions(stations []string) ([]Predictions, error)
- func (dmv *DmvApi) FetchTrainIncidents() ([]Incident, error)
- func (dmv *DmvApi) GetCodeFromArg(arg string) []string
- func (dmv *DmvApi) GetColorFromLine(line string) (string, string)
- func (dmv *DmvApi) IsGhostTrain(line, destination string) bool
- type Incident
- type IncidentsResponse
- type Predictions
- type PredictionsResponse
- type WMATA_Incident
Constants ¶
View Source
const (
DATETIME_LAYOUT = "2006-01-02T15:04:05"
)
View Source
const (
DMV_BASE_URL = "https://api.wmata.com"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Api ¶
type Api interface { // Fetches arrival information for list of location unique identifiers FetchPredictions(ids []string) ([]Predictions, error) // Fetch train incidents for a location FetchTrainIncidents() ([]Incident, error) // Given user input for a location, returns the unique identifier (location could have multiple) GetCodeFromArg(arg string) []string // Given a line name or abbreviation, return colors that represents it. // (fg, bg) tuple returned GetColorFromLine(arg string) (string, string) // Determines if a train isn't for passengers IsGhostTrain(line, destination string) bool }
type DmvApi ¶
type DmvApi struct {
// contains filtered or unexported fields
}
API to interact with WMATA
func (*DmvApi) FetchPredictions ¶ added in v1.1.0
func (dmv *DmvApi) FetchPredictions(stations []string) ([]Predictions, error)
func (*DmvApi) FetchTrainIncidents ¶ added in v1.2.0
func (*DmvApi) GetCodeFromArg ¶ added in v1.1.0
func (*DmvApi) GetColorFromLine ¶ added in v1.2.1
func (*DmvApi) IsGhostTrain ¶ added in v1.2.1
type Incident ¶ added in v1.2.0
type Incident struct { // Message from the transit authority describing the situation Description string // Last date & time update from the transit authority DateUpdated time.Time // Lines, stations or stops affected by the incident Affected []string // Type of incident Type string }
Disruptions and/or delays data
type IncidentsResponse ¶ added in v1.2.0
type IncidentsResponse struct {
Incidents []WMATA_Incident
}
type Predictions ¶ added in v1.1.0
type Predictions struct { // Minutes until a train arrives Min string // The short name for a train station LocationName string // The short name for the train's destination Destination string // The full name for the train's destination DestinationName string // The train's line Line string }
Next train arrival prediction data
type PredictionsResponse ¶ added in v1.1.0
type PredictionsResponse struct {
Trains []Predictions
}
WMATA's predictions API response
Click to show internal directories.
Click to hide internal directories.