mirror of
https://github.com/sstent/go-garminconnect.git
synced 2026-01-31 11:32:15 +00:00
with garth
This commit is contained in:
@@ -8,17 +8,17 @@ import (
|
||||
|
||||
// UserProfile represents a Garmin Connect user profile
|
||||
type UserProfile struct {
|
||||
DisplayName string `json:"displayName"`
|
||||
FullName string `json:"fullName"`
|
||||
EmailAddress string `json:"emailAddress"`
|
||||
Username string `json:"username"`
|
||||
ProfileID string `json:"profileId"`
|
||||
ProfileImage string `json:"profileImageUrlLarge"`
|
||||
Location string `json:"location"`
|
||||
FitnessLevel string `json:"fitnessLevel"`
|
||||
Height float64 `json:"height"`
|
||||
Weight float64 `json:"weight"`
|
||||
Birthdate string `json:"birthDate"`
|
||||
DisplayName string `json:"displayName"`
|
||||
FullName string `json:"fullName"`
|
||||
EmailAddress string `json:"emailAddress"`
|
||||
Username string `json:"username"`
|
||||
ProfileID string `json:"profileId"`
|
||||
ProfileImage string `json:"profileImageUrlLarge"`
|
||||
Location string `json:"location"`
|
||||
FitnessLevel string `json:"fitnessLevel"`
|
||||
Height float64 `json:"height"`
|
||||
Weight float64 `json:"weight"`
|
||||
Birthdate string `json:"birthDate"`
|
||||
}
|
||||
|
||||
// UserStats represents fitness statistics for a user
|
||||
@@ -35,16 +35,16 @@ type UserStats struct {
|
||||
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 {
|
||||
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 +52,7 @@ 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