-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 1.1 KB
/
main.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
37
38
39
40
41
42
43
package main
import (
"flag"
"fmt"
"github.com/LeonLyx/sg-bus-api/api"
)
func main() {
var accountKey string
flag.StringVar(&accountKey, "account-key", "your-account-key", "required for endpoint access")
flag.Parse()
client := api.NewBusAPIClient(accountKey)
busArrival, err := client.GetBusArrival("83139", "15")
if err != nil {
fmt.Printf("error getting bus arrival, %s\n", err.Error())
} else if len(busArrival.Services) > 0 {
fmt.Printf("%+v\n", busArrival.Services[0])
}
busServices, err := client.GetBusServices()
if err != nil {
fmt.Printf("error getting bus services, %s\n", err.Error())
} else if len(busServices.Services) > 0 {
fmt.Printf("%+v\n", busServices.Services[0])
}
busStops, err := client.GetBusStops()
if err != nil {
fmt.Printf("error getting bus stops, %s\n", err.Error())
} else if len(busStops.BusStops) > 0 {
fmt.Printf("%+v\n", busStops.BusStops[0])
}
busRoutes, err := client.GetBusRoutes()
if err != nil {
fmt.Printf("error getting bus routes, %s\n", err.Error())
} else if len(busRoutes.Routes) > 0 {
fmt.Printf("%+v\n", busRoutes.Routes[0])
}
}