mirror of
https://github.com/sstent/go-garth.git
synced 2026-02-04 05:22:12 +00:00
sync - build broken
This commit is contained in:
34
python-garmin-connect/LifetimeActivities.go
Normal file
34
python-garmin-connect/LifetimeActivities.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package connect
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
// LifetimeActivities is describing a basic summary of all activities.
|
||||
type LifetimeActivities struct {
|
||||
Activities int `json:"totalActivities"` // The number of activities
|
||||
Distance float64 `json:"totalDistance"` // The total distance in meters
|
||||
Duration float64 `json:"totalDuration"` // The duration of all activities in seconds
|
||||
Calories float64 `json:"totalCalories"` // Energy in C
|
||||
ElevationGain float64 `json:"totalElevationGain"` // Total elevation gain in meters
|
||||
}
|
||||
|
||||
// LifetimeActivities will return some aggregated data about all activities.
|
||||
func (c *Client) LifetimeActivities(displayName string) (*LifetimeActivities, error) {
|
||||
URL := "https://connect.garmin.com/modern/proxy/userstats-service/statistics/" + displayName
|
||||
|
||||
var proxy struct {
|
||||
Activities []LifetimeActivities `json:"userMetrics"`
|
||||
}
|
||||
|
||||
err := c.getJSON(URL, &proxy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(proxy.Activities) != 1 {
|
||||
return nil, errors.New("unexpected data")
|
||||
}
|
||||
|
||||
return &proxy.Activities[0], err
|
||||
}
|
||||
Reference in New Issue
Block a user