mirror of
https://github.com/sstent/go-garth.git
synced 2026-02-06 14:32:22 +00:00
sync - build broken
This commit is contained in:
41
python-garmin-connect/ActivityHrZones.go
Normal file
41
python-garmin-connect/ActivityHrZones.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package connect
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ActivityHrZones describes the heart-rate zones during an activity.
|
||||
type ActivityHrZones struct {
|
||||
TimeInZone time.Duration `json:"secsInZone"`
|
||||
ZoneLowBoundary int `json:"zoneLowBoundary"`
|
||||
ZoneNumber int `json:"zoneNumber"`
|
||||
}
|
||||
|
||||
// ActivityHrZones returns the reported heart-rate zones for an activity.
|
||||
func (c *Client) ActivityHrZones(activityID int) ([]ActivityHrZones, error) {
|
||||
URL := fmt.Sprintf("https://connect.garmin.com/modern/proxy/activity-service/activity/%d/hrTimeInZones",
|
||||
activityID,
|
||||
)
|
||||
|
||||
var proxy []struct {
|
||||
TimeInZone float64 `json:"secsInZone"`
|
||||
ZoneLowBoundary int `json:"zoneLowBoundary"`
|
||||
ZoneNumber int `json:"zoneNumber"`
|
||||
}
|
||||
|
||||
err := c.getJSON(URL, &proxy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
zones := make([]ActivityHrZones, len(proxy))
|
||||
|
||||
for i, p := range proxy {
|
||||
zones[i].TimeInZone = time.Duration(p.TimeInZone * float64(time.Second))
|
||||
zones[i].ZoneLowBoundary = p.ZoneLowBoundary
|
||||
zones[i].ZoneNumber = p.ZoneNumber
|
||||
}
|
||||
|
||||
return zones, nil
|
||||
}
|
||||
Reference in New Issue
Block a user