mirror of
https://github.com/sstent/go-garth.git
synced 2026-04-05 16:52:45 +00:00
working auth and activity list
This commit is contained in:
23
main.go
23
main.go
@@ -36,6 +36,19 @@ type SessionData struct {
|
|||||||
AuthToken string `json:"auth_token"`
|
AuthToken string `json:"auth_token"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActivityType represents the type of activity
|
||||||
|
type ActivityType struct {
|
||||||
|
TypeID int `json:"typeId"`
|
||||||
|
TypeKey string `json:"typeKey"`
|
||||||
|
ParentTypeID *int `json:"parentTypeId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventType represents the event type of an activity
|
||||||
|
type EventType struct {
|
||||||
|
TypeID int `json:"typeId"`
|
||||||
|
TypeKey string `json:"typeKey"`
|
||||||
|
}
|
||||||
|
|
||||||
// Activity represents a Garmin Connect activity
|
// Activity represents a Garmin Connect activity
|
||||||
type Activity struct {
|
type Activity struct {
|
||||||
ActivityID int64 `json:"activityId"`
|
ActivityID int64 `json:"activityId"`
|
||||||
@@ -43,8 +56,8 @@ type Activity struct {
|
|||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
StartTimeLocal string `json:"startTimeLocal"`
|
StartTimeLocal string `json:"startTimeLocal"`
|
||||||
StartTimeGMT string `json:"startTimeGMT"`
|
StartTimeGMT string `json:"startTimeGMT"`
|
||||||
ActivityType string `json:"activityType"`
|
ActivityType ActivityType `json:"activityType"`
|
||||||
EventType string `json:"eventType"`
|
EventType EventType `json:"eventType"`
|
||||||
Distance float64 `json:"distance"`
|
Distance float64 `json:"distance"`
|
||||||
Duration float64 `json:"duration"`
|
Duration float64 `json:"duration"`
|
||||||
ElapsedDuration float64 `json:"elapsedDuration"`
|
ElapsedDuration float64 `json:"elapsedDuration"`
|
||||||
@@ -54,8 +67,8 @@ type Activity struct {
|
|||||||
AverageSpeed float64 `json:"averageSpeed"`
|
AverageSpeed float64 `json:"averageSpeed"`
|
||||||
MaxSpeed float64 `json:"maxSpeed"`
|
MaxSpeed float64 `json:"maxSpeed"`
|
||||||
Calories float64 `json:"calories"`
|
Calories float64 `json:"calories"`
|
||||||
AverageHR int `json:"averageHR"`
|
AverageHR float64 `json:"averageHR"`
|
||||||
MaxHR int `json:"maxHR"`
|
MaxHR float64 `json:"maxHR"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OAuth1Token represents OAuth1 token response
|
// OAuth1Token represents OAuth1 token response
|
||||||
@@ -734,7 +747,7 @@ func main() {
|
|||||||
fmt.Printf("\n=== Recent Activities ===\n")
|
fmt.Printf("\n=== Recent Activities ===\n")
|
||||||
for i, activity := range activities {
|
for i, activity := range activities {
|
||||||
fmt.Printf("%d. %s\n", i+1, activity.ActivityName)
|
fmt.Printf("%d. %s\n", i+1, activity.ActivityName)
|
||||||
fmt.Printf(" Type: %s\n", activity.ActivityType)
|
fmt.Printf(" Type: %s\n", activity.ActivityType.TypeKey)
|
||||||
fmt.Printf(" Date: %s\n", activity.StartTimeLocal)
|
fmt.Printf(" Date: %s\n", activity.StartTimeLocal)
|
||||||
if activity.Distance > 0 {
|
if activity.Distance > 0 {
|
||||||
fmt.Printf(" Distance: %.2f km\n", activity.Distance/1000)
|
fmt.Printf(" Distance: %.2f km\n", activity.Distance/1000)
|
||||||
|
|||||||
Reference in New Issue
Block a user