-
Notifications
You must be signed in to change notification settings - Fork 0
/
station.go
36 lines (32 loc) · 933 Bytes
/
station.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package humphrey
import (
"encoding/xml"
"fmt"
"net/url"
)
// Station stubs out the BART Station interface
type Station struct {
Abbreviation string `xml:"abbr"`
Name string `xml:"name"`
Latitude float32 `xml:"gtfs_latitude"`
Longitude float32 `xml:"gtfs_longitude"`
Address string `xml:"address"`
City string `xml:"city"`
County string `xml:"county"`
State string `xml:"state"`
ZIPCode string `xml:"zipcode"`
}
type stationsResponse struct {
XMLName xml.Name `xml:"root"`
Stations []Station `xml:"stations>station"`
Message string `xml:"message"`
}
// GetAllStations gets all the BART stations
func (c *Client) GetAllStations() ([]Station, error) {
var response stationsResponse
err := c.MakeRequest("stn", "stns", url.Values{}, &response)
if err != nil {
return nil, fmt.Errorf("making 'stns' request: %v", err)
}
return response.Stations, nil
}