mirror of
https://github.com/sstent/go-garth.git
synced 2026-02-01 20:11:49 +00:00
sync
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// GarminTime represents Garmin's timestamp format with custom JSON parsing
|
||||
type GarminTime struct {
|
||||
time.Time
|
||||
}
|
||||
|
||||
// UnmarshalJSON handles Garmin's timestamp format
|
||||
func (gt *GarminTime) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
t, err := time.Parse("2006-01-02T15:04:05", s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gt.Time = t
|
||||
return nil
|
||||
}
|
||||
|
||||
// Client represents the Garmin Connect client
|
||||
type Client struct {
|
||||
Domain string
|
||||
@@ -65,6 +85,14 @@ type OAuth1Token struct {
|
||||
Domain string `json:"domain"`
|
||||
}
|
||||
|
||||
// UserProfile represents a Garmin user profile
|
||||
type UserProfile struct {
|
||||
UserName string `json:"userName"`
|
||||
DisplayName string `json:"displayName"`
|
||||
LevelUpdateDate GarminTime `json:"levelUpdateDate"`
|
||||
// Add other fields as needed from API response
|
||||
}
|
||||
|
||||
// OAuth2Token represents OAuth2 token response
|
||||
type OAuth2Token struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
|
||||
Reference in New Issue
Block a user