mirror of
https://github.com/sstent/go-garminconnect.git
synced 2026-02-01 20:11:44 +00:00
env working but auth not yet
This commit is contained in:
@@ -23,28 +23,20 @@ type UserProfile struct {
|
||||
|
||||
// UserStats represents fitness statistics for a user
|
||||
type UserStats struct {
|
||||
TotalSteps int `json:"totalSteps"`
|
||||
TotalDistance float64 `json:"totalDistance"` // in meters
|
||||
TotalCalories int `json:"totalCalories"`
|
||||
ActiveMinutes int `json:"activeMinutes"`
|
||||
RestingHR int `json:"restingHeartRate"`
|
||||
Date time.Time `json:"date"`
|
||||
TotalSteps int `json:"totalSteps"`
|
||||
TotalDistance float64 `json:"totalDistance"` // in meters
|
||||
TotalCalories int `json:"totalCalories"`
|
||||
ActiveMinutes int `json:"activeMinutes"`
|
||||
RestingHR int `json:"restingHeartRate"`
|
||||
Date string `json:"date"` // Store as string in "YYYY-MM-DD" format
|
||||
}
|
||||
|
||||
// GetUserProfile retrieves the user's profile information
|
||||
func (c *Client) GetUserProfile(ctx context.Context) (*UserProfile, error) {
|
||||
var profile UserProfile
|
||||
path := "/userprofile-service/socialProfile"
|
||||
|
||||
if err := c.Get(ctx, path, &profile); err != nil {
|
||||
if err := c.Get(ctx, "/userprofile-service/socialProfile", &profile); err != nil {
|
||||
return nil, fmt.Errorf("failed to get user profile: %w", err)
|
||||
}
|
||||
|
||||
// Handle empty profile response
|
||||
if profile.ProfileID == "" {
|
||||
return nil, fmt.Errorf("user profile not found")
|
||||
}
|
||||
|
||||
return &profile, nil
|
||||
}
|
||||
|
||||
@@ -52,7 +44,6 @@ func (c *Client) GetUserProfile(ctx context.Context) (*UserProfile, error) {
|
||||
func (c *Client) GetUserStats(ctx context.Context, date time.Time) (*UserStats, error) {
|
||||
var stats UserStats
|
||||
path := fmt.Sprintf("/stats-service/stats/daily/%s", date.Format("2006-01-02"))
|
||||
|
||||
if err := c.Get(ctx, path, &stats); err != nil {
|
||||
return nil, fmt.Errorf("failed to get user stats: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user