Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct {
Value string `json:"access_token"`
Type string `json:"token_type"`
ExpiresIn uint `json:"expires_in"`
XUserID uint64 `json:"x_user_id"`
}
AccessToken is the response of the Authorization.
type Client ¶
type Client interface {
// AuthorizationURL returns the URL to get the authorization from the user.
AuthorizationURL(string) string
// AuthorizationAccessToken get an access token from the user code.
AuthorizationAccessToken(string) (AccessToken, error)
// Exercises returns the exercises of the user.
Exercises() ([]Exercise, error)
// SetBearer
SetBearer(string)
// SetUserID
SetUserID(uint64)
// RegisterUser register a new user to polar the application.
RegisterUser() error
// UnregisterUser remove an user from the polar application.
UnregisterUser() error
// User returns information about the current user.
User() (u User, err error)
// LastRecharges returns information about the last 28 night recharges.
LastRecharges() ([]Recharge, error)
// LastSleeps returns information about the last 28 days of sleep.
LastSleeps() ([]Sleep, error)
// Recharge returns information about the recharge of the given date.
Recharge(string) (Recharge, error)
// Sleep returns information of sleep for the given date.
Sleep(string) (Sleep, error)
}
Client is the client interface of Polar service.
type Config ¶
type Config struct {
Host string `json:"host" env:"POLAR_HOST"`
LimitRate uint8 `json:"limit_rate" env:"POLAR_LIMITRATE"`
Timeout uint16 `json:"timeout" env:"POLAR_TIMETOUT"`
ClientID string `json:"client_id" env:"POLAR_ID"`
ClientSecret string `json:"client_secret" env:"POLAR_SECRET"`
// contains filtered or unexported fields
}
Config is the configuration for the client to request Polar API.
func (*Config) AuthorizationToken ¶
AuthorizationToken return the token based on configuration.
type Exercise ¶
type Exercise struct {
ID string `json:"id"`
Sport string `json:"sport"`
Device string `json:"device"`
HasRoute bool `json:"has_route"`
Calories float64 `json:"calories"`
Distance float64 `json:"distance"`
TrainingLoad float64 `json:"training_load"`
FatPercentage uint8 `json:"fat_percentage"`
ProteinPercentage uint8 `json:"protein_percentage"`
CarbohydratePercentage uint8 `json:"carbohydrate_percentage"`
Duration string `json:"duration"`
StartTime string `json:"start_time"`
HeartRate struct {
Average uint16 `json:"average"`
Maximum uint16 `json:"maximum"`
} `json:"heart_rate"`
}
Exercise is the representation of an Polar exercise.
type Recharge ¶
type Recharge struct {
Date string `json:"date"`
HeartRateAvg uint64 `json:"heart_rate_avg"`
BeatToBeatAvg uint64 `json:"beat_to_beat_avg"`
HeartRateVariabilityAvg uint64 `json:"heart_rate_variability_avg"`
BreathingRateAvg float64 `json:"breathing_rate_avg"`
ANSCharge float64 `json:"ans_charge"`
}
Recharge is the representation of a Polar "Nightly Recharge".
type RequestParams ¶
type RequestParams struct {
Queries types.Map
Values types.Map
WithBearer bool
WithFormURLEncoded bool
}
RequestParams define the parameters to request the API.
type Sleep ¶
type Sleep struct {
Continuity float64 `json:"continuity"`
Score uint64 `json:"sleep_score"`
Light uint64 `json:"light_sleep"`
Deep uint64 `json:"deep_sleep"`
Rem uint64 `json:"rem_sleep"`
Interruption uint64 `json:"total_interruption_duration"`
DeviceID string `json:"device_id"`
// Dates
Start types.DateTime `json:"sleep_start_time"`
End types.DateTime `json:"sleep_end_time"`
}
Sleep is the representation of an Polar sleep.
Click to show internal directories.
Click to hide internal directories.