bart

package module
v0.0.0-...-17da949 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2016 License: MIT Imports: 3 Imported by: 0

README

bart-api

A Golang package for the BART API. Currently supports Advisories, Station Info, and Real Time Estimates.

Usage

	bartClient := bart.New()

	bsaResp, _ := bartClient.Advisories.Bsa(&bart.BsaRequest{Orig: "all"})
	fmt.Printf("Advisories.Bsa = %#v\n\n", bsaResp)

	countResp, _ := bartClient.Advisories.TrainCount(&bart.CountRequest{})
	fmt.Printf("Advisories.Count = %#v\n\n", countResp)

	elevResp, _ := bartClient.Advisories.ElevatorStatus(&bart.ElevRequest{})
	fmt.Printf("Advisories.Elev = %#v\n\n", elevResp)

	helpResp, _ := bartClient.Advisories.Help(&bart.HelpRequest{})
	fmt.Printf("Advisories.Help = %#v\n\n", helpResp)

	stationResp, _ := bartClient.StationInfo.Stations(&bart.StationListRequest{})
	fmt.Printf("StationInfo.Stations = %#v\n\n", stationResp)

	stationAccessResp, _ := bartClient.StationInfo.StationAccess(&bart.StationAccessRequest{Origin: "12th", LegendEnabled: 1})
	fmt.Printf("StationInfo.StationAccess = %#v\n\n", stationAccessResp)

	stationInfoResp, _ := bartClient.StationInfo.StationInfo(&bart.StationInfoRequest{Origin: "12th"})
	fmt.Printf("StationInfo.StationInfo = %#v\n\n", stationInfoResp)

	stationHelpResp, _ := bartClient.StationInfo.Help(&bart.HelpRequest{})
	fmt.Printf("StationInfo.Help = %#v\n\n", stationHelpResp)

	deptResp, _ := bartClient.RealTimeEstimates.Departures(&bart.EstimateDepartureRequest{Origin: "12th"})
	fmt.Printf("RealTimeEstimates.Departures = %#v\n\n", deptResp)

	estimateHelpResp, _ := bartClient.RealTimeEstimates.Help(&bart.HelpRequest{})
	fmt.Printf("RealTimeEstimates.Help = %#v\n\n", estimateHelpResp)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvisoryService

type AdvisoryService struct{}

func (*AdvisoryService) Bsa

func (s *AdvisoryService) Bsa(r *BsaRequest) (resp BsaResponse, err error)

func (*AdvisoryService) ElevatorStatus

func (s *AdvisoryService) ElevatorStatus(r *ElevRequest) (resp BsaResponse, err error)

func (*AdvisoryService) Help

func (s *AdvisoryService) Help(r *HelpRequest) (resp HelpResponse, err error)

func (*AdvisoryService) TrainCount

func (s *AdvisoryService) TrainCount(r *CountRequest) (resp CountResponse, err error)

type BartClient

type BartClient struct {
	Advisories        *AdvisoryService
	StationInfo       *StationInfoService
	RealTimeEstimates *RealTimeEstimateService
}

func New

func New() BartClient

type BartResponseMeta

type BartResponseMeta struct {
	Uri     string `xml:"uri"`
	Date    string `xml:"date"`
	Time    string `xml:"time"`
	Message string `xml:"message"`
}

type Bsa

type Bsa struct {
	Station     string `xml:"station"`
	Description string `xml:"description"`
	SmsText     string `xml:"sms_text"`
}

type BsaRequest

type BsaRequest struct {
	Orig string `url:"orig"`
}

type BsaResponse

type BsaResponse struct {
	BartResponseMeta
	Bsa Bsa `xml:"bsa"`
}

type CountRequest

type CountRequest struct{}

type CountResponse

type CountResponse struct {
	BartResponseMeta
	TrainCount int `xml:"traincount"`
}

type Departure

type Departure struct {
	Destination  string     `xml:"destination"`
	Abbreviation string     `xml:"abbreviation"`
	Limited      int        `xml:"limited"`
	Estimates    []Estimate `xml:"estimate"`
}

type DepartureStation

type DepartureStation struct {
	Name       string      `xml:"name"`
	Abbr       string      `xml:"abbr"`
	Departures []Departure `xml:"etd"`
}

type ElevRequest

type ElevRequest struct{}

type Estimate

type Estimate struct {
	Minutes   int    `xml:"minutes"`
	Platform  int    `xml:"platform"`
	Direction string `xml:"direction"`
	Length    int    `xml:"length"`
	Color     string `xml:"color"`
	HexColor  string `xml:"hexcolor"`
	BikeFlag  int    `xml:"bikeflag"`
}

type EstimateDepartureRequest

type EstimateDepartureRequest struct {
	Origin    string `url:"orig"`
	Platform  string `url:"plat,omitempty"`
	Direction string `url:"dir,omitempty"`
}

type EstimateDepartureResponse

type EstimateDepartureResponse struct {
	BartResponseMeta
	Station DepartureStation `xml:"station"`
}

type HelpRequest

type HelpRequest struct{}

type HelpResponse

type HelpResponse struct {
	BartResponseMeta
	Message Message `xml:"message"`
}

type Message

type Message struct {
	Help string `xml:"help"`
}

type RealTimeEstimateService

type RealTimeEstimateService struct{}

func (*RealTimeEstimateService) Departures

type Station

type Station struct {
	Name      string  `xml:"name"`
	Abbr      string  `xml:"abbr"`
	Latitude  float64 `xml:"gtfs_latitude"`
	Longitude float64 `xml:"gtfs_longitude"`
	Address   string  `xml:"address"`
	City      string  `xml:"city"`
	County    string  `xml:"county"`
	State     string  `xml:"state"`
	ZipCode   string  `xml:"zipcode"`
}

type StationAccess

type StationAccess struct {
	Name            string `xml:"name"`
	Abbr            string `xml:"abbr"`
	Link            string `xml:"link"`
	ParkingFlag     int    `xml:"parking_flag,attr"`
	BikeFlag        int    `xml:"bike_flag,attr"`
	BikeStationFlag int    `xml:"bike_station_flag,attr"`
	LockerFlag      int    `xml:"locker_flag,attr"`
	Entering        string `xml:"entering"`
	Exiting         string `xml:"exiting"`
	Parking         string `xml:"parking"`
	FillTime        string `xml:"fill_time"`
	CarShare        string `xml:"car_share"`
	Lockers         string `xml:"lockers"`
	BikeStationText string `xml:"bike_station_text"`
	Destinations    string `xml:"destinations"`
	TransitInfo     string `xml:"transit_info"`
}

type StationAccessRequest

type StationAccessRequest struct {
	Origin        string `url:"orig"`
	LegendEnabled int    `url:"l"`
}

type StationAccessResponse

type StationAccessResponse struct {
	BartResponseMeta
	Station StationAccess `xml:"stations>station"`
	Legend  string        `xml:"message>legend"`
}

type StationDetail

type StationDetail struct {
	Station
	NorthRoutes    []string `xml:"north_routes>route"`
	SouthRoutes    []string `xml:"south_routes>route"`
	NorthPlatforms []string `xml:"north_platforms>platform"`
	SouthPlatforms []string `xml:"south_platforms>platform"`
	PlatformInfo   string   `xml:"platform_info"`
	Intro          string   `xml:"intro"`
	CrossStreet    string   `xml:"cross_street"`
	Food           string   `xml:"food"`
	Shopping       string   `xml:"shopping"`
	Attraction     string   `xml:"attraction"`
}

type StationInfoRequest

type StationInfoRequest struct {
	Origin string `url:"orig"`
}

type StationInfoResponse

type StationInfoResponse struct {
	BartResponseMeta
	Station StationDetail `xml:"stations>station"`
}

type StationInfoService

type StationInfoService struct{}

func (*StationInfoService) Help

func (s *StationInfoService) Help(r *HelpRequest) (resp HelpResponse, err error)

func (*StationInfoService) StationAccess

func (s *StationInfoService) StationAccess(r *StationAccessRequest) (resp StationAccessResponse, err error)

func (*StationInfoService) StationInfo

func (s *StationInfoService) StationInfo(r *StationInfoRequest) (resp StationInfoResponse, err error)

func (*StationInfoService) Stations

func (s *StationInfoService) Stations(r *StationListRequest) (resp StationListResponse, err error)

type StationListRequest

type StationListRequest struct{}

type StationListResponse

type StationListResponse struct {
	BartResponseMeta
	Stations []Station `xml:"stations>station"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL