api

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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
}

func GetClient added in v0.4.1

func GetClient(location string) Api

type DmvApi

type DmvApi struct {
	// contains filtered or unexported fields
}

API to interact with WMATA

func DmvClient

func DmvClient() *DmvApi

Build and return a client for the DMV Metro

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 (dmv *DmvApi) FetchTrainIncidents() ([]Incident, error)

func (*DmvApi) GetCodeFromArg added in v1.1.0

func (dmv *DmvApi) GetCodeFromArg(arg string) []string

func (*DmvApi) GetColorFromLine added in v1.2.1

func (dmv *DmvApi) GetColorFromLine(line string) (string, string)

func (*DmvApi) IsGhostTrain added in v1.2.1

func (dmv *DmvApi) IsGhostTrain(line, destination string) bool

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

type WMATA_Incident added in v1.2.0

type WMATA_Incident struct {
	Description   string
	IncidentType  string
	LinesAffected string
	DateUpdated   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳