mirror of
https://github.com/sstent/go-garth.git
synced 2026-01-27 09:31:47 +00:00
This commit implements the package structure refactoring as outlined in phase1.md (Task 1A.1). Key changes include: - Reorganized packages into `pkg/garmin` for public API and `internal/` for internal implementations. - Updated all import paths to reflect the new structure. - Consolidated types and client logic into their respective new packages. - Updated `cmd/garth/main.go` to use the new public API. - Fixed various compilation and test issues encountered during the refactoring process. - Converted `internal/api/client/auth_test.go` to a functional test. This establishes a solid foundation for future enhancements and improves maintainability.
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package garmin
|
|
|
|
import (
|
|
"garmin-connect/internal/data"
|
|
"time"
|
|
)
|
|
|
|
// BodyBatteryData represents Body Battery data.
|
|
type BodyBatteryData = data.DailyBodyBatteryStress
|
|
|
|
// SleepData represents sleep data.
|
|
type SleepData = data.DailySleepDTO
|
|
|
|
// HRVData represents HRV data.
|
|
type HRVData = data.HRVData
|
|
|
|
// WeightData represents weight data.
|
|
type WeightData = data.WeightData
|
|
|
|
// GetBodyBattery retrieves Body Battery data for a given date.
|
|
func (c *Client) GetBodyBattery(date time.Time) (*BodyBatteryData, error) {
|
|
bb := &data.DailyBodyBatteryStress{}
|
|
result, err := bb.Get(date, c.Client)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return result.(*BodyBatteryData), nil
|
|
}
|
|
|
|
// GetSleep retrieves sleep data for a given date.
|
|
func (c *Client) GetSleep(date time.Time) (*SleepData, error) {
|
|
sleep := &data.DailySleepDTO{}
|
|
result, err := sleep.Get(date, c.Client)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return result.(*SleepData), nil
|
|
}
|
|
|
|
// GetHRV retrieves HRV data for a given date.
|
|
func (c *Client) GetHRV(date time.Time) (*HRVData, error) {
|
|
hrv := &data.HRVData{}
|
|
result, err := hrv.Get(date, c.Client)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return result.(*HRVData), nil
|
|
}
|
|
|
|
// GetWeight retrieves weight data for a given date.
|
|
func (c *Client) GetWeight(date time.Time) (*WeightData, error) {
|
|
weight := &data.WeightData{}
|
|
result, err := weight.Get(date, c.Client)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return result.(*WeightData), nil
|
|
}
|