Documentation
¶
Index ¶
- Constants
- func Marshal(payload *Payload, w io.Writer) error
- func MarshalToString(payload *Payload) (string, error)
- type AggregatedSleepAnalysis
- type Datapoint
- type DatapointFields
- type DatapointWithUnit
- type Elevation
- type Field
- type Metric
- type Payload
- type PayloadData
- type Qty
- type QtyWithUnit
- type RouteDatapoint
- type SleepAnalysis
- type Time
- type Units
- type Workout
- type WorkoutFields
Constants ¶
const ( // TimeFormat is the format to parse time.Time in this package. TimeFormat = "2006-01-02 15:04:05 -0700" SleepAnalysisName = "sleep_analysis" )
Variables ¶
This section is empty.
Functions ¶
func MarshalToString ¶
MarshalToString marshals payload to a string.
Types ¶
type AggregatedSleepAnalysis ¶ added in v0.3.0
type AggregatedSleepAnalysis struct { // Start time of sleep. SleepStart *Time `json:"sleepStart"` // End time of sleep. SleepEnd *Time `json:"sleepEnd"` // InBed duration in hours. InBed Qty `json:"inBed"` // Asleep duration in hours. Asleep Qty `json:"asleep"` // Awake duration in hours. // Only available from HAE v6.6.2 onwards. Awake Qty `json:"awake,omitempty"` // Core sleep duration in hours. // Only available from HAE v6.6.2 onwards. Core Qty `json:"core,omitempty"` // Deep sleep duration in hours. // Only available from HAE v6.6.2 onwards. Deep Qty `json:"deep,omitempty"` // REM sleep duration in hours. // Only available from HAE v6.6.2 onwards. REM Qty `json:"rem,omitempty"` // Start time of inBed phase. // Only available prior to HAE v6.6.2. InBedStart *Time `json:"inBedStart,omitempty"` // End time of inBed phase. // Only available prior to HAE v6.6.2. InBedEnd *Time `json:"inBedEnd,omitempty"` // Data source of sleep data. // Multiple source names will be joined together with a pipe (|). // Only available from HAE v6.6.2 onwards. Source string `json:"source,omitempty"` // Data source of sleep phase. // Only available prior to HAE v6.6.2. SleepSource string `json:"sleepSource,omitempty"` // Data source of inBed phase. // Only available prior to HAE v6.6.2. InBedSource string `json:"inBedSource,omitempty"` }
AggregatedSleepAnalysis defines an aggregated period of an entire night of sleep. It is only valid for aggregate sleep analysis data ("Aggregate Sleep Data" is enabled)
type Datapoint ¶
type Datapoint struct { Date *Time `json:"date"` // Qty may not be specified for some types of metrics. Qty Qty `json:"qty,omitempty"` // Other fields. Fields DatapointFields `json:"-"` }
Datapoint is a point-in-time value of a metric.
func (*Datapoint) MarshalJSON ¶
func (*Datapoint) UnmarshalJSON ¶
UnmarshalJSON implements a custom json.Unmarshaler for Datapoint. This is necessary to unmarshal arbitrary DatapointFields.
type DatapointFields ¶
type DatapointFields map[string]interface{}
DatapointFields is a map of fields with an arbitrary type in a single Datapoint.
type DatapointWithUnit ¶
type DatapointWithUnit struct { Date *Time `json:"date"` QtyWithUnit }
DatapointWithUnit is a point-in-time value of a QtyWithUnit.
type Elevation ¶
type Elevation struct { Units Units `json:"units"` Ascent Qty `json:"ascent"` Descent Qty `json:"descent"` }
Elevation is a specify QtyWithUnit that specifies Ascent and Descent values. It is only used for the Elevation field.
type Field ¶ added in v0.3.0
type Field struct { Key string Value *QtyWithUnit }
type Metric ¶
type Metric struct { Name string `json:"name"` Units Units `json:"units"` Datapoints []*Datapoint `json:"-"` SleepAnalyses []*SleepAnalysis `json:"-"` AggregatedSleepAnalyses []*AggregatedSleepAnalysis `json:"-"` }
Metric defines a single measurement with units, as well as time-series data points.
func (*Metric) MarshalJSON ¶ added in v0.2.0
func (*Metric) UnmarshalJSON ¶ added in v0.2.0
type Payload ¶
type Payload struct {
Data *PayloadData `json:"data,omitempty"`
}
func UnmarshalFromString ¶
UnmarshalFromString unmarshals payload from a string.
type PayloadData ¶
type QtyWithUnit ¶
QtyWithUnit combines a Qty with Units of measurement.
func (QtyWithUnit) GetUnits ¶
func (q QtyWithUnit) GetUnits() Units
type RouteDatapoint ¶
type RouteDatapoint struct { Lat float64 `json:"lat"` Lon float64 `json:"lon"` Altitude float64 `json:"altitude"` Timestamp *Time `json:"timestamp"` }
RouteDatapoint is a point-in-time location in 3D coordinates.
type SleepAnalysis ¶ added in v0.2.0
type SleepAnalysis struct { StartDate *Time `json:"startDate"` EndDate *Time `json:"endDate"` Qty Qty `json:"qty,omitempty"` Source string `json:"source"` Value string `json:"value"` }
SleepAnalysis defines a period during sleep of various types (Value). It is only valid for non-aggregate sleep analysis data ("Aggregate Sleep Data" is disabled)
type Time ¶
Time is a custom time type for this package.
func (Time) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. This implementation overrides the default time.Time json.Marshaler implementation, and marshals using TimeFormat.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. This implementation overrides the default time.Time json.Unmarshaler implementation, and parses timestamps using TimeFormat.
type Workout ¶
type Workout struct { Name string `json:"name"` Start *Time `json:"start"` End *Time `json:"end"` // Route data Route []*RouteDatapoint `json:"route,omitempty"` // Heart rate data. HeartRateData []*DatapointWithUnit `json:"heartRateData,omitempty"` HeartRateRecovery []*DatapointWithUnit `json:"heartRateRecovery,omitempty"` // Elevation data. Elevation *Elevation `json:"elevation,omitempty"` // Other workout fields. Fields WorkoutFields `json:"-"` }
Workout defines a single recorded Workout.
func (*Workout) MarshalJSON ¶
func (*Workout) UnmarshalJSON ¶
UnmarshalJSON implements a custom json.Unmarshaler for Workout. This is necessary to unmarshal arbitrary Fields that may match QtyWithUnit.
type WorkoutFields ¶
type WorkoutFields []Field
WorkoutFields is a map of generic QtyWithUnit fields in a Workout.