diff --git a/garth/data/hrv.go b/garth/data/hrv.go new file mode 100644 index 0000000..f36adf2 --- /dev/null +++ b/garth/data/hrv.go @@ -0,0 +1,68 @@ +package data + +import ( + "sort" + "time" + + "garmin-connect/garth/client" +) + +// HRVSummary represents Heart Rate Variability summary data +type HRVSummary struct { + UserProfilePK int `json:"userProfilePk"` + CalendarDate time.Time `json:"calendarDate"` + StartTimestampGMT time.Time `json:"startTimestampGmt"` + EndTimestampGMT time.Time `json:"endTimestampGmt"` + // Add other fields from Python implementation +} + +// HRVReading represents an individual HRV reading +type HRVReading struct { + Timestamp int `json:"timestamp"` + StressLevel int `json:"stressLevel"` + HeartRate int `json:"heartRate"` + RRInterval int `json:"rrInterval"` + Status string `json:"status"` + SignalQuality float64 `json:"signalQuality"` +} + +// HRVData represents complete HRV data +type HRVData struct { + UserProfilePK int `json:"userProfilePk"` + HRVSummary HRVSummary `json:"hrvSummary"` + HRVReadings []HRVReading `json:"hrvReadings"` + BaseData +} + +// ParseHRVReadings converts values array to structured readings +func ParseHRVReadings(valuesArray [][]any) []HRVReading { + readings := make([]HRVReading, 0) + for _, values := range valuesArray { + if len(values) < 6 { + continue + } + + // Extract values with type assertions + // Add parsing logic based on Python implementation + + readings = append(readings, HRVReading{ + // Initialize fields + }) + } + sort.Slice(readings, func(i, j int) bool { + return readings[i].Timestamp < readings[j].Timestamp + }) + return readings +} + +// Get implements the Data interface for HRVData +func (h *HRVData) Get(day time.Time, client *client.Client) (any, error) { + // Implementation to be added + return nil, nil +} + +// List implements the Data interface for concurrent fetching +func (h *HRVData) List(end time.Time, days int, client *client.Client, maxWorkers int) ([]any, error) { + // Implementation to be added + return []any{}, nil +} diff --git a/garth/data/sleep.go b/garth/data/sleep.go new file mode 100644 index 0000000..89e0836 --- /dev/null +++ b/garth/data/sleep.go @@ -0,0 +1,48 @@ +package data + +import ( + "time" + + "garmin-connect/garth/client" +) + +// SleepScores represents sleep scoring data +type SleepScores struct { + TotalSleepSeconds int `json:"totalSleepSeconds"` + SleepScores []struct { + StartTimeGMT time.Time `json:"startTimeGmt"` + EndTimeGMT time.Time `json:"endTimeGmt"` + SleepScore int `json:"sleepScore"` + } `json:"sleepScores"` + SleepMovement []SleepMovement `json:"sleepMovement"` + // Add other fields from Python implementation +} + +// SleepMovement represents movement during sleep +type SleepMovement struct { + StartGMT time.Time `json:"startGmt"` + EndGMT time.Time `json:"endGmt"` + ActivityLevel int `json:"activityLevel"` +} + +// DailySleepDTO represents daily sleep data +type DailySleepDTO struct { + UserProfilePK int `json:"userProfilePk"` + CalendarDate time.Time `json:"calendarDate"` + SleepStartTimestampGMT time.Time `json:"sleepStartTimestampGmt"` + SleepEndTimestampGMT time.Time `json:"sleepEndTimestampGmt"` + SleepScores SleepScores `json:"sleepScores"` + BaseData +} + +// Get implements the Data interface for DailySleepDTO +func (d *DailySleepDTO) Get(day time.Time, client *client.Client) (any, error) { + // Implementation to be added + return nil, nil +} + +// List implements the Data interface for concurrent fetching +func (d *DailySleepDTO) List(end time.Time, days int, client *client.Client, maxWorkers int) ([]any, error) { + // Implementation to be added + return []any{}, nil +} diff --git a/garth/data/weight.go b/garth/data/weight.go new file mode 100644 index 0000000..d91fd60 --- /dev/null +++ b/garth/data/weight.go @@ -0,0 +1,39 @@ +package data + +import ( + "errors" + "time" + + "garmin-connect/garth/client" +) + +// WeightData represents weight measurement data +type WeightData struct { + UserProfilePK int `json:"userProfilePk"` + CalendarDate time.Time `json:"calendarDate"` + Timestamp time.Time `json:"timestamp"` + Weight float64 `json:"weight"` // in kilograms + BMI float64 `json:"bmi"` + BodyFatPercentage float64 `json:"bodyFatPercentage"` + BaseData +} + +// Validate checks if weight data contains valid values +func (w *WeightData) Validate() error { + if w.Weight <= 0 { + return errors.New("invalid weight value") + } + return nil +} + +// Get implements the Data interface for WeightData +func (w *WeightData) Get(day time.Time, client *client.Client) (any, error) { + // Implementation to be added + return nil, nil +} + +// List implements the Data interface for concurrent fetching +func (w *WeightData) List(end time.Time, days int, client *client.Client, maxWorkers int) ([]any, error) { + // Implementation to be added + return []any{}, nil +}