feat(refactor): Implement 1A.1 Package Structure Refactoring

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.
This commit is contained in:
2025-09-18 13:13:39 -07:00
parent c00ea67f31
commit 2fdfbea34e
57 changed files with 876 additions and 297 deletions

58
pkg/garmin/health.go Normal file
View File

@@ -0,0 +1,58 @@
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
}