mirror of
https://github.com/sstent/go-garth.git
synced 2025-12-06 08:01:42 +00:00
reworked api interfaces
This commit is contained in:
@@ -2,7 +2,7 @@ package garmin_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/sstent/go-garth/internal/api/client"
|
||||
"github.com/sstent/go-garth/pkg/garth/client"
|
||||
"github.com/sstent/go-garth/internal/data"
|
||||
"github.com/sstent/go-garth/internal/testutils"
|
||||
"testing"
|
||||
|
||||
@@ -8,9 +8,8 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
internalClient "github.com/sstent/go-garth/internal/api/client"
|
||||
internalClient "github.com/sstent/go-garth/pkg/garth/client"
|
||||
"github.com/sstent/go-garth/internal/errors"
|
||||
types "github.com/sstent/go-garth/internal/models/types"
|
||||
shared "github.com/sstent/go-garth/shared/interfaces"
|
||||
models "github.com/sstent/go-garth/shared/models"
|
||||
)
|
||||
@@ -51,12 +50,12 @@ func (c *Client) GetUserSettings() (*models.UserSettings, error) {
|
||||
}
|
||||
|
||||
// GetUserProfile implements the APIClient interface
|
||||
func (c *Client) GetUserProfile() (*types.UserProfile, error) {
|
||||
func (c *Client) GetUserProfile() (*UserProfile, error) {
|
||||
return c.Client.GetUserProfile()
|
||||
}
|
||||
|
||||
// GetWellnessData implements the APIClient interface
|
||||
func (c *Client) GetWellnessData(startDate, endDate time.Time) ([]types.WellnessData, error) {
|
||||
func (c *Client) GetWellnessData(startDate, endDate time.Time) ([]WellnessData, error) {
|
||||
return c.Client.GetWellnessData(startDate, endDate)
|
||||
}
|
||||
|
||||
@@ -168,72 +167,72 @@ func (c *Client) SearchActivities(query string) ([]Activity, error) {
|
||||
}
|
||||
|
||||
// GetSleepData retrieves sleep data for a specified date range
|
||||
func (c *Client) GetSleepData(date time.Time) (*types.DetailedSleepData, error) {
|
||||
func (c *Client) GetSleepData(date time.Time) (*DetailedSleepData, error) {
|
||||
return c.Client.GetDetailedSleepData(date)
|
||||
}
|
||||
|
||||
// GetHrvData retrieves HRV data for a specified number of days
|
||||
func (c *Client) GetHrvData(date time.Time) (*types.DailyHRVData, error) {
|
||||
func (c *Client) GetHrvData(date time.Time) (*DailyHRVData, error) {
|
||||
return c.Client.GetDailyHRVData(date)
|
||||
}
|
||||
|
||||
// GetStressData retrieves stress data
|
||||
func (c *Client) GetStressData(startDate, endDate time.Time) ([]types.StressData, error) {
|
||||
func (c *Client) GetStressData(startDate, endDate time.Time) ([]StressData, error) {
|
||||
return c.Client.GetStressData(startDate, endDate)
|
||||
}
|
||||
|
||||
// GetBodyBatteryData retrieves Body Battery data
|
||||
func (c *Client) GetBodyBatteryData(date time.Time) (*types.DetailedBodyBatteryData, error) {
|
||||
func (c *Client) GetBodyBatteryData(date time.Time) (*DetailedBodyBatteryData, error) {
|
||||
return c.Client.GetDetailedBodyBatteryData(date)
|
||||
}
|
||||
|
||||
// GetStepsData retrieves steps data for a specified date range
|
||||
func (c *Client) GetStepsData(startDate, endDate time.Time) ([]types.StepsData, error) {
|
||||
func (c *Client) GetStepsData(startDate, endDate time.Time) ([]StepsData, error) {
|
||||
return c.Client.GetStepsData(startDate, endDate)
|
||||
}
|
||||
|
||||
// GetDistanceData retrieves distance data for a specified date range
|
||||
func (c *Client) GetDistanceData(startDate, endDate time.Time) ([]types.DistanceData, error) {
|
||||
func (c *Client) GetDistanceData(startDate, endDate time.Time) ([]DistanceData, error) {
|
||||
return c.Client.GetDistanceData(startDate, endDate)
|
||||
}
|
||||
|
||||
// GetCaloriesData retrieves calories data for a specified date range
|
||||
func (c *Client) GetCaloriesData(startDate, endDate time.Time) ([]types.CaloriesData, error) {
|
||||
func (c *Client) GetCaloriesData(startDate, endDate time.Time) ([]CaloriesData, error) {
|
||||
return c.Client.GetCaloriesData(startDate, endDate)
|
||||
}
|
||||
|
||||
// GetVO2MaxData retrieves VO2 max data for a specified date range
|
||||
func (c *Client) GetVO2MaxData(startDate, endDate time.Time) ([]types.VO2MaxData, error) {
|
||||
func (c *Client) GetVO2MaxData(startDate, endDate time.Time) ([]VO2MaxData, error) {
|
||||
return c.Client.GetVO2MaxData(startDate, endDate)
|
||||
}
|
||||
|
||||
// GetHeartRateZones retrieves heart rate zone data
|
||||
func (c *Client) GetHeartRateZones() (*types.HeartRateZones, error) {
|
||||
func (c *Client) GetHeartRateZones() (*HeartRateZones, error) {
|
||||
return c.Client.GetHeartRateZones()
|
||||
}
|
||||
|
||||
// GetTrainingStatus retrieves current training status
|
||||
func (c *Client) GetTrainingStatus(date time.Time) (*types.TrainingStatus, error) {
|
||||
func (c *Client) GetTrainingStatus(date time.Time) (*TrainingStatus, error) {
|
||||
return c.Client.GetTrainingStatus(date)
|
||||
}
|
||||
|
||||
// GetTrainingLoad retrieves training load data
|
||||
func (c *Client) GetTrainingLoad(date time.Time) (*types.TrainingLoad, error) {
|
||||
func (c *Client) GetTrainingLoad(date time.Time) (*TrainingLoad, error) {
|
||||
return c.Client.GetTrainingLoad(date)
|
||||
}
|
||||
|
||||
// GetFitnessAge retrieves fitness age calculation
|
||||
func (c *Client) GetFitnessAge() (*types.FitnessAge, error) {
|
||||
func (c *Client) GetFitnessAge() (*FitnessAge, error) {
|
||||
// TODO: Implement GetFitnessAge in internalClient.Client
|
||||
return nil, fmt.Errorf("GetFitnessAge not implemented in internalClient.Client")
|
||||
}
|
||||
|
||||
// OAuth1Token returns the OAuth1 token
|
||||
func (c *Client) OAuth1Token() *types.OAuth1Token {
|
||||
func (c *Client) OAuth1Token() *OAuth1Token {
|
||||
return c.Client.OAuth1Token
|
||||
}
|
||||
|
||||
// OAuth2Token returns the OAuth2 token
|
||||
func (c *Client) OAuth2Token() *types.OAuth2Token {
|
||||
func (c *Client) OAuth2Token() *OAuth2Token {
|
||||
return c.Client.OAuth2Token
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
internalClient "github.com/sstent/go-garth/internal/api/client"
|
||||
internalClient "github.com/sstent/go-garth/pkg/garth/client"
|
||||
"github.com/sstent/go-garth/internal/models/types"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/sstent/go-garth/internal/api/client"
|
||||
"github.com/sstent/go-garth/pkg/garth/client"
|
||||
"github.com/sstent/go-garth/internal/data"
|
||||
"github.com/sstent/go-garth/internal/stats"
|
||||
)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package garmin
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/sstent/go-garth/internal/stats"
|
||||
)
|
||||
|
||||
@@ -38,21 +36,3 @@ func NewDailySleep() Stats {
|
||||
func NewDailyHRV() Stats {
|
||||
return stats.NewDailyHRV()
|
||||
}
|
||||
|
||||
// StepsData represents steps statistics
|
||||
type StepsData struct {
|
||||
Date time.Time `json:"calendarDate"`
|
||||
Steps int `json:"steps"`
|
||||
}
|
||||
|
||||
// DistanceData represents distance statistics
|
||||
type DistanceData struct {
|
||||
Date time.Time `json:"calendarDate"`
|
||||
Distance float64 `json:"distance"` // in meters
|
||||
}
|
||||
|
||||
// CaloriesData represents calories statistics
|
||||
type CaloriesData struct {
|
||||
Date time.Time `json:"calendarDate"`
|
||||
Calories int `json:"activeCalories"`
|
||||
}
|
||||
@@ -1,90 +1,99 @@
|
||||
package garmin
|
||||
|
||||
import types "github.com/sstent/go-garth/internal/models/types"
|
||||
import garth "github.com/sstent/go-garth/pkg/garth/types"
|
||||
|
||||
// GarminTime represents Garmin's timestamp format with custom JSON parsing
|
||||
type GarminTime = types.GarminTime
|
||||
type GarminTime = garth.GarminTime
|
||||
|
||||
// SessionData represents saved session information
|
||||
type SessionData = types.SessionData
|
||||
type SessionData = garth.SessionData
|
||||
|
||||
// ActivityType represents the type of activity
|
||||
type ActivityType = types.ActivityType
|
||||
type ActivityType = garth.ActivityType
|
||||
|
||||
// EventType represents the event type of an activity
|
||||
type EventType = types.EventType
|
||||
type EventType = garth.EventType
|
||||
|
||||
// Activity represents a Garmin Connect activity
|
||||
type Activity = types.Activity
|
||||
type Activity = garth.Activity
|
||||
|
||||
// UserProfile represents a Garmin user profile
|
||||
type UserProfile = types.UserProfile
|
||||
type UserProfile = garth.UserProfile
|
||||
|
||||
// OAuth1Token represents OAuth1 token response
|
||||
type OAuth1Token = types.OAuth1Token
|
||||
type OAuth1Token = garth.OAuth1Token
|
||||
|
||||
// OAuth2Token represents OAuth2 token response
|
||||
type OAuth2Token = types.OAuth2Token
|
||||
type OAuth2Token = garth.OAuth2Token
|
||||
|
||||
// DetailedSleepData represents comprehensive sleep data
|
||||
type DetailedSleepData = types.DetailedSleepData
|
||||
type DetailedSleepData = garth.DetailedSleepData
|
||||
|
||||
// SleepLevel represents different sleep stages
|
||||
type SleepLevel = types.SleepLevel
|
||||
type SleepLevel = garth.SleepLevel
|
||||
|
||||
// SleepMovement represents movement during sleep
|
||||
type SleepMovement = types.SleepMovement
|
||||
type SleepMovement = garth.SleepMovement
|
||||
|
||||
// SleepScore represents detailed sleep scoring
|
||||
type SleepScore = types.SleepScore
|
||||
type SleepScore = garth.SleepScore
|
||||
|
||||
// SleepScoreBreakdown represents breakdown of sleep score
|
||||
type SleepScoreBreakdown = types.SleepScoreBreakdown
|
||||
type SleepScoreBreakdown = garth.SleepScoreBreakdown
|
||||
|
||||
// HRVBaseline represents HRV baseline data
|
||||
type HRVBaseline = types.HRVBaseline
|
||||
type HRVBaseline = garth.HRVBaseline
|
||||
|
||||
// DailyHRVData represents comprehensive daily HRV data
|
||||
type DailyHRVData = types.DailyHRVData
|
||||
type DailyHRVData = garth.DailyHRVData
|
||||
|
||||
// BodyBatteryEvent represents events that impact Body Battery
|
||||
type BodyBatteryEvent = types.BodyBatteryEvent
|
||||
type BodyBatteryEvent = garth.BodyBatteryEvent
|
||||
|
||||
// DetailedBodyBatteryData represents comprehensive Body Battery data
|
||||
type DetailedBodyBatteryData = types.DetailedBodyBatteryData
|
||||
type DetailedBodyBatteryData = garth.DetailedBodyBatteryData
|
||||
|
||||
// TrainingStatus represents current training status
|
||||
type TrainingStatus = types.TrainingStatus
|
||||
type TrainingStatus = garth.TrainingStatus
|
||||
|
||||
// TrainingLoad represents training load data
|
||||
type TrainingLoad = types.TrainingLoad
|
||||
type TrainingLoad = garth.TrainingLoad
|
||||
|
||||
// FitnessAge represents fitness age calculation
|
||||
type FitnessAge = types.FitnessAge
|
||||
type FitnessAge = garth.FitnessAge
|
||||
|
||||
// VO2MaxData represents VO2 max data
|
||||
type VO2MaxData = types.VO2MaxData
|
||||
type VO2MaxData = garth.VO2MaxData
|
||||
|
||||
// VO2MaxEntry represents a single VO2 max entry
|
||||
type VO2MaxEntry = types.VO2MaxEntry
|
||||
type VO2MaxEntry = garth.VO2MaxEntry
|
||||
|
||||
// HeartRateZones represents heart rate zone data
|
||||
type HeartRateZones = types.HeartRateZones
|
||||
type HeartRateZones = garth.HeartRateZones
|
||||
|
||||
// HRZone represents a single heart rate zone
|
||||
type HRZone = types.HRZone
|
||||
type HRZone = garth.HRZone
|
||||
|
||||
// WellnessData represents additional wellness metrics
|
||||
type WellnessData = types.WellnessData
|
||||
type WellnessData = garth.WellnessData
|
||||
|
||||
// SleepData represents sleep summary data
|
||||
type SleepData = types.SleepData
|
||||
type SleepData = garth.SleepData
|
||||
|
||||
// HrvData represents Heart Rate Variability data
|
||||
type HrvData = types.HrvData
|
||||
type HrvData = garth.HrvData
|
||||
|
||||
// StressData represents stress level data
|
||||
type StressData = types.StressData
|
||||
type StressData = garth.StressData
|
||||
|
||||
// BodyBatteryData represents Body Battery data
|
||||
type BodyBatteryData = types.BodyBatteryData
|
||||
type BodyBatteryData = garth.BodyBatteryData
|
||||
|
||||
// StepsData represents steps statistics
|
||||
type StepsData = garth.StepsData
|
||||
|
||||
// DistanceData represents distance statistics
|
||||
type DistanceData = garth.DistanceData
|
||||
|
||||
// CaloriesData represents calories statistics
|
||||
type CaloriesData = garth.CaloriesData
|
||||
|
||||
Reference in New Issue
Block a user