-
Notifications
You must be signed in to change notification settings - Fork 1
/
mode.go
37 lines (30 loc) · 1.08 KB
/
mode.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
package tfl
import (
"context"
"fmt"
"strconv"
)
// GetActiveServiceTypes returns the service type active for a mode. Currently only supports tube.
//
// https://api.tfl.gov.uk/swagger/ui/index.html?url=/swagger/docs/v1#!/Mode/Mode_GetActiveServiceTypes
func (c *Client) GetActiveServiceTypes(ctx context.Context) ([]ActiveServiceType, error) {
path := "/Mode/ActiveServiceTypes"
activeServiceTypes := []ActiveServiceType{}
err := c.get(ctx, path, &activeServiceTypes)
if err != nil {
return nil, err
}
return activeServiceTypes, err
}
// GetArrivalPredictionsForMode gets the next arrival predictions for all stops of a given mode.
//
// https://api.tfl.gov.uk/swagger/ui/index.html?url=/swagger/docs/v1#!/Mode/Mode_Arrivals
func (c *Client) GetArrivalPredictionsForMode(ctx context.Context, mode string, count int) ([]Prediction, error) {
path := fmt.Sprintf("/Mode/%s/Arrivals", mode)
predictions := []Prediction{}
err := c.getWithQueryParams(ctx, path, map[string]string{"count": strconv.Itoa(count)}, &predictions)
if err != nil {
return nil, err
}
return predictions, err
}