Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to access the Fitbit API
func (Client) GetHeartRateLogs ¶
func (client Client) GetHeartRateLogs(date time.Time, resolution DataResolution) ([]HeartRateMeasurement, error)
GetHeartRateLogs returns all heartrate time series for a given date
func (Client) GetSleepLogs ¶
func (client Client) GetSleepLogs(date time.Time) ([]SleepLogEntry, error)
GetSleepLogs returns all sleep logs for a specific date
type Config ¶
type Config struct { CallbackServerPort int ClientID string ClientSecret string Scopes []Scope TokenPath string }
Config is the API client config
type DataResolution ¶
type DataResolution = string
DataResolution determines the granularity of the heart rate data
const ( OneSecondResolution DataResolution = "1sec" OneMinuteResolution DataResolution = "1min" )
Available resolution levels
type HeartRateMeasurement ¶
HeartRateMeasurement represents the heartrate at a point in time
type LocalDate ¶
LocalDate is used to parse the date fields in the API
func (*LocalDate) UnmarshalJSON ¶
UnmarshalJSON parses the date string from the JSON response
type LocalTime ¶
LocalTime is used to parse time fields in the API
func (*LocalTime) UnmarshalJSON ¶
UnmarshalJSON parses the time string from the JSON response
type MillisecondDuration ¶
MillisecondDuration is used to parse millisecond durations in the API
func (*MillisecondDuration) UnmarshalJSON ¶
func (duration *MillisecondDuration) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the milliseconds int from the JSON response
type MinuteDuration ¶
MinuteDuration is used to parse minute durations in the API
func (*MinuteDuration) UnmarshalJSON ¶
func (duration *MinuteDuration) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the minutes int from the JSON response
type SecondDuration ¶
SecondDuration is used to parse second durations in the API
func (*SecondDuration) UnmarshalJSON ¶
func (duration *SecondDuration) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the seconds int from the JSON response
type SleepData ¶
type SleepData struct { Summary map[SleepPhase]SleepSummary `json:"summary"` Timeline []SleepEvent `json:"data"` }
SleepData contains the summary and details for a sleep
type SleepEvent ¶
type SleepEvent struct { Date LocalDate `json:"datetime"` Phase SleepPhase `json:"level"` Duration SecondDuration `json:"seconds"` }
SleepEvent is a sleep phase in the sleep timeline
type SleepLogEntry ¶
type SleepLogEntry struct { ID int64 `json:"logId"` Duration MillisecondDuration `json:"duration"` StartDate LocalDate `json:"startTime"` EndDate LocalDate `json:"endTime"` Data SleepData `json:"levels"` }
SleepLogEntry represents a single sleep
type SleepPhase ¶
type SleepPhase = string
SleepPhase represents a sleep phase
const ( Awake SleepPhase = "wake" Deep SleepPhase = "deep" Light SleepPhase = "light" REM SleepPhase = "rem" )
Enum of all sleep phases
type SleepSummary ¶
type SleepSummary struct { Count int `json:"count"` Duration MinuteDuration `json:"minutes"` }
SleepSummary is the summary of a sleep phase