Documentation ¶
Index ¶
- Variables
- func AuthCodeURL(c *AuthConfig) string
- func GetAlarmsRequest(ctx context.Context, param *GetAlarmsParam) (*http.Request, error)
- func GetBodyFatLogsRequest(ctx context.Context, param *BodyFatLogsParam) (*http.Request, error)
- func GetDevicesRequest(ctx context.Context) (*http.Request, error)
- func GetHeartRateIntradayTimeSeriesRequest(ctx context.Context, param *HeartRateParam) (*http.Request, error)
- func GetProfileRequest(ctx context.Context) (*http.Request, error)
- func GetSleepLogsRequest(ctx context.Context, param *SleepLogsParam) (*http.Request, error)
- func GetTokenStateRequest(ctx context.Context, access_token string) (*http.Request, error)
- func GetWeightLogsRequest(ctx context.Context, param *WeightLogsParam) (*http.Request, error)
- func ImplicitURL(c *AuthConfig, expires string) string
- type ActivitiesHeart
- type ActivitiesHeartIntraday
- type Alarm
- type Alarms
- type AuthConfig
- type BodyFat
- type BodyFatLogs
- type BodyFatLogsParam
- type Client
- func (c *Client) Do(r *http.Request) (*Response, error)
- func (api *Client) GetAlaramsContext(ctx context.Context, param *GetAlarmsParam) (*Alarms, *Response, error)
- func (api *Client) GetAlarms(param *GetAlarmsParam) (*Alarms, *Response, error)
- func (api *Client) GetBodyFatLogs(param *BodyFatLogsParam) (*BodyFatLogs, *Response, error)
- func (api *Client) GetBodyFatLogsContext(ctx context.Context, param *BodyFatLogsParam) (*BodyFatLogs, *Response, error)
- func (api *Client) GetDevices() (*Devices, *Response, error)
- func (api *Client) GetDevicesContext(ctx context.Context) (*Devices, *Response, error)
- func (api *Client) GetHeartRateIntradayTimeSeries(param *HeartRateParam) (*HeartRateData, *Response, error)
- func (api *Client) GetHeartRateIntradayTimeSeriesContext(ctx context.Context, param *HeartRateParam) (*HeartRateData, *Response, error)
- func (api *Client) GetProfile() (*Profile, *Response, error)
- func (api *Client) GetProfileContext(ctx context.Context) (*Profile, *Response, error)
- func (api *Client) GetSleepLogs(param *SleepLogsParam) (*SleepLogs, *Response, error)
- func (api *Client) GetSleepLogsContext(ctx context.Context, param *SleepLogsParam) (*SleepLogs, *Response, error)
- func (api *Client) GetTokenState(access_token string) (*TokenState, *Response, error)
- func (api *Client) GetTokenStateContext(ctx context.Context, access_token string) (*TokenState, *Response, error)
- func (api *Client) GetWeightLogs(param *WeightLogsParam) (*WeightLogs, *Response, error)
- func (api *Client) GetWeightLogsContext(ctx context.Context, param *WeightLogsParam) (*WeightLogs, *Response, error)
- func (c *Client) Token() (Token, error)
- type Device
- type Devices
- type ErrorResponse
- type GetAlarmsParam
- type HeartRateData
- type HeartRateParam
- type Profile
- type RateLimit
- type Response
- type Sleep
- type SleepLogs
- type SleepLogsParam
- type Summary
- type Token
- type TokenState
- type User
- type Weight
- type WeightLogs
- type WeightLogsParam
Constants ¶
This section is empty.
Variables ¶
var (
DefaultHttpClient = &http.Client{Timeout: 30 * time.Second}
)
var (
ErrRequestUnknown = errors.New("unknown error") // TODO put into other file
)
Functions ¶
func AuthCodeURL ¶
func AuthCodeURL(c *AuthConfig) string
AuthCodeURL returns the URL to fitibit auth page with authorization code grant flow. expires_in parameter is default 8hours.
func GetAlarmsRequest ¶
GetAlarms is based on GET https://api.fitbit.com/1/user/[user-id]/devices/tracker/[tracker-id]/alarms.json
func GetBodyFatLogsRequest ¶
func GetSleepLogsRequest ¶
func GetTokenStateRequest ¶
func GetWeightLogsRequest ¶
func ImplicitURL ¶
func ImplicitURL(c *AuthConfig, expires string) string
ImplicitURL returns the URL to fitbit auth page with implicit grant flow. Expires parameter can be one of 86400(1day) 604800(1week) 2592000(30days) 31536000(1year)
Types ¶
type ActivitiesHeart ¶
type ActivitiesHeart struct { DateTime string `json:"dateTime"` Value struct { CustomHeartRateZones []interface{} `json:"customHeartRateZones"` HeartRateZones []struct { CaloriesOut float64 `json:"caloriesOut"` Max int `json:"max"` Min int `json:"min"` Minutes int `json:"minutes"` Name string `json:"name"` } `json:"heartRateZones"` RestingHeartRate int `json:"restingHeartRate"` } `json:"value"` }
type ActivitiesHeartIntraday ¶
type Alarm ¶
type Alarm struct { AlarmID int `json:"alarmId"` Deleted bool `json:"deleted"` Enabled bool `json:"enabled"` Recurring bool `json:"recurring"` SnoozeCount int `json:"snoozeCount"` SnoozeLength int `json:"snoozeLength"` SyncedToDevice bool `json:"syncedToDevice"` Time string `json:"time"` Vibe string `json:"vibe"` WeekDays []interface{} `json:"weekDays"` }
type Alarms ¶
type Alarms struct {
TrackerAlarms []Alarm `json:"trackerAlarms"`
}
func GetAlarams ¶
func GetAlarams(c *Client, param *GetAlarmsParam) (*Alarms, error)
func GetAlaramsContext ¶
type AuthConfig ¶
type BodyFatLogs ¶
type BodyFatLogs struct {
Fat []BodyFat `json:"fat"`
}
func GetBodyFatLogs ¶
func GetBodyFatLogs(c *Client, param *BodyFatLogsParam) (*BodyFatLogs, error)
func GetBodyFatLogsContext ¶
func GetBodyFatLogsContext(ctx context.Context, c *Client, param *BodyFatLogsParam) (*BodyFatLogs, error)
type BodyFatLogsParam ¶
type BodyFatLogsParam struct { Date string `validate:"len=0|datetime=2006-01-02"` Period string `validate:"len=0|oneof=1d 7d 30d 1w 1m"` BaseDate string `validate:"len=0|datetime=2006-01-02"` EndDate string `validate:"len=0|datetime=2006-01-02"` }
GET https://api.fitbit.com/1/user/[user-id]/body/log/fat/date/[date].json GET https://api.fitbit.com/1/user/[user-id]/body/log/fat/date/[date]/[period].json GET https://api.fitbit.com/1/user/[user-id]/body/log/fat/date/[base-date]/[end-date].json
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Do ¶
Do returns raw response without processing Body responsed. The Caller must handle Body.Close() function
func (*Client) GetAlaramsContext ¶
func (*Client) GetAlarms ¶
func (api *Client) GetAlarms(param *GetAlarmsParam) (*Alarms, *Response, error)
func (*Client) GetBodyFatLogs ¶
func (api *Client) GetBodyFatLogs(param *BodyFatLogsParam) (*BodyFatLogs, *Response, error)
func (*Client) GetBodyFatLogsContext ¶
func (api *Client) GetBodyFatLogsContext(ctx context.Context, param *BodyFatLogsParam) (*BodyFatLogs, *Response, error)
func (*Client) GetDevicesContext ¶
func (*Client) GetHeartRateIntradayTimeSeries ¶
func (api *Client) GetHeartRateIntradayTimeSeries(param *HeartRateParam) (*HeartRateData, *Response, error)
func (*Client) GetHeartRateIntradayTimeSeriesContext ¶
func (api *Client) GetHeartRateIntradayTimeSeriesContext(ctx context.Context, param *HeartRateParam) (*HeartRateData, *Response, error)
func (*Client) GetProfileContext ¶
func (*Client) GetSleepLogs ¶
func (api *Client) GetSleepLogs(param *SleepLogsParam) (*SleepLogs, *Response, error)
func (*Client) GetSleepLogsContext ¶
func (*Client) GetTokenState ¶
func (api *Client) GetTokenState(access_token string) (*TokenState, *Response, error)
func (*Client) GetTokenStateContext ¶
func (*Client) GetWeightLogs ¶
func (api *Client) GetWeightLogs(param *WeightLogsParam) (*WeightLogs, *Response, error)
func (*Client) GetWeightLogsContext ¶
func (api *Client) GetWeightLogsContext(ctx context.Context, param *WeightLogsParam) (*WeightLogs, *Response, error)
type Device ¶
type Device struct { Battery string `json:"battery"` BatteryLevel int `json:"batteryLevel"` DeviceVersion string `json:"deviceVersion"` Features []interface{} `json:"features"` ID string `json:"id"` LastSyncTime string `json:"lastSyncTime"` Mac string `json:"mac"` Type string `json:"type"` }
generated by json-to-go
type ErrorResponse ¶
type ErrorResponse struct { Errors []struct { ErrorType string `json:"errorType"` Message string `json:"message"` } `json:"errors"` Success bool `json:"success"` }
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type GetAlarmsParam ¶
type GetAlarmsParam struct {
TrackerID string
}
type HeartRateData ¶
type HeartRateData struct { ActivitiesHeart []ActivitiesHeart `json:"activities-heart"` ActivitiesHeartIntraday ActivitiesHeartIntraday `json:"activities-heart-intraday"` }
func GetHeartRateIntradayTimeSeries ¶
func GetHeartRateIntradayTimeSeries(c *Client, param *HeartRateParam) (*HeartRateData, error)
func GetHeartRateIntradayTimeSeriesContext ¶
func GetHeartRateIntradayTimeSeriesContext(ctx context.Context, c *Client, param *HeartRateParam) (*HeartRateData, error)
type HeartRateParam ¶
type HeartRateParam struct { Date string `validate:"len=0|datetime=2006-01-02"` EndDate string `validate:"len=0|datetime=2006-01-02"` DetailLevel string `validate:"oneof=1sec 1min"` StartTime string `validate:"len=0|datetime=15:04"` EndTime string `validate:"len=0|datetime=15:04"` }
Get Heart Rate Intraday Time Series Personal App Type is requeired
GET https://api.fitbit.com/1/user/-/activities/heart/date/[date]/[end-date]/[detail-level].json GET https://api.fitbit.com/1/user/-/activities/heart/date/[date]/[end-date]/[detail-level]/time/[start-time]/[end-time].json GET https://api.fitbit.com/1/user/-/activities/heart/date/[date]/1d/[detail-level].json` GET https://api.fitbit.com/1/user/-/activities/heart/date/[date]/1d/[detail-level]/time/[start-time]/[end-time].json
type Response ¶
Response is a wrapper for http.Response received from fitbit api
func (*Response) OutputWithIndent ¶
TODO refactor
type Sleep ¶
type Sleep struct { DateOfSleep string `json:"dateOfSleep"` Duration int `json:"duration"` Efficiency int `json:"efficiency"` EndTime string `json:"endTime"` InfoCode int `json:"infoCode"` IsMainSleep bool `json:"isMainSleep"` Levels struct { Data []struct { DateTime string `json:"dateTime"` Level string `json:"level"` Seconds int `json:"seconds"` } `json:"data"` ShortData []struct { DateTime string `json:"dateTime"` Level string `json:"level"` Seconds int `json:"seconds"` } `json:"shortData"` Summary struct { Deep struct { Count int `json:"count"` Minutes int `json:"minutes"` ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"` } `json:"deep"` Light struct { Count int `json:"count"` Minutes int `json:"minutes"` ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"` } `json:"light"` Rem struct { Count int `json:"count"` Minutes int `json:"minutes"` ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"` } `json:"rem"` Wake struct { Count int `json:"count"` Minutes int `json:"minutes"` ThirtyDayAvgMinutes int `json:"thirtyDayAvgMinutes"` } `json:"wake"` } `json:"summary"` } `json:"levels"` LogID int64 `json:"logId"` MinutesAfterWakeup int `json:"minutesAfterWakeup"` MinutesAsleep int `json:"minutesAsleep"` MinutesAwake int `json:"minutesAwake"` MinutesToFallAsleep int `json:"minutesToFallAsleep"` StartTime string `json:"startTime"` TimeInBed int `json:"timeInBed"` Type string `json:"type"` }
type SleepLogs ¶
func GetSleepLogs ¶
func GetSleepLogs(c *Client, param *SleepLogsParam) (*SleepLogs, error)
func GetSleepLogsContext ¶
type SleepLogsParam ¶
type SleepLogsParam struct { Date string `validate:"len=0|datetime=2006-01-02"` StartDate string `validate:"len=0|datetime=2006-01-02"` EndDate string `validate:"len=0|datetime=2006-01-02"` }
GET https://api.fitbit.com/1.2/user/[user-id]/sleep/date/[date].json GET https://api.fitbit.com/1.2/user/[user-id]/sleep/date/[startDate]/[endDate].json
type Token ¶
type Token struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token,omitempty"` Expiry time.Time `json:"expiry,omitempty"` }
func GenerateToken ¶
func GenerateToken(c *AuthConfig, code string) (Token, error)
GenerateToken returns the Token generated by authorization code grant flow.
type TokenState ¶
type TokenState struct { Active bool `json:"active"` Scope string `json:"scope"` ClientID string `json:"client_id"` UserID string `json:"user_id"` TokenType string `json:"token_type"` Exp int64 `json:"exp"` Iat int64 `json:"iat"` }
func GetTokenState ¶
func GetTokenState(c *Client, access_token string) (*TokenState, error)
func GetTokenStateContext ¶
type User ¶
type User struct { Age int `json:"age"` Ambassador bool `json:"ambassador"` Avatar string `json:"avatar"` Avatar150 string `json:"avatar150"` Avatar640 string `json:"avatar640"` AverageDailySteps int `json:"averageDailySteps"` ChallengesBeta bool `json:"challengesBeta"` ClockTimeDisplayFormat string `json:"clockTimeDisplayFormat"` Corporate bool `json:"corporate"` CorporateAdmin bool `json:"corporateAdmin"` Country string `json:"country"` DateOfBirth string `json:"dateOfBirth"` DisplayName string `json:"displayName"` DisplayNameSetting string `json:"displayNameSetting"` DistanceUnit string `json:"distanceUnit"` EncodedID string `json:"encodedId"` Features struct { ExerciseGoal bool `json:"exerciseGoal"` } `json:"features"` FoodsLocale string `json:"foodsLocale"` FullName string `json:"fullName"` Gender string `json:"gender"` GlucoseUnit string `json:"glucoseUnit"` Height float64 `json:"height"` HeightUnit string `json:"heightUnit"` IsBugReportEnabled bool `json:"isBugReportEnabled"` IsChild bool `json:"isChild"` IsCoach bool `json:"isCoach"` LanguageLocale string `json:"languageLocale"` LegalTermsAcceptRequired bool `json:"legalTermsAcceptRequired"` Locale string `json:"locale"` MemberSince string `json:"memberSince"` MfaEnabled bool `json:"mfaEnabled"` OffsetFromUTCMillis int `json:"offsetFromUTCMillis"` SdkDeveloper bool `json:"sdkDeveloper"` SleepTracking string `json:"sleepTracking"` StartDayOfWeek string `json:"startDayOfWeek"` StrideLengthRunning float64 `json:"strideLengthRunning"` StrideLengthRunningType string `json:"strideLengthRunningType"` StrideLengthWalking float64 `json:"strideLengthWalking"` StrideLengthWalkingType string `json:"strideLengthWalkingType"` SwimUnit string `json:"swimUnit"` Timezone string `json:"timezone"` TopBadges []struct { BadgeGradientEndColor string `json:"badgeGradientEndColor"` BadgeGradientStartColor string `json:"badgeGradientStartColor"` BadgeType string `json:"badgeType"` Category string `json:"category"` Cheers []interface{} `json:"cheers"` DateTime string `json:"dateTime"` Description string `json:"description"` EarnedMessage string `json:"earnedMessage"` EncodedID string `json:"encodedId"` Image100Px string `json:"image100px"` Image125Px string `json:"image125px"` Image300Px string `json:"image300px"` Image50Px string `json:"image50px"` Image75Px string `json:"image75px"` MarketingDescription string `json:"marketingDescription"` MobileDescription string `json:"mobileDescription"` Name string `json:"name"` ShareImage640Px string `json:"shareImage640px"` ShareText string `json:"shareText"` ShortDescription string `json:"shortDescription"` ShortName string `json:"shortName"` TimesAchieved int `json:"timesAchieved"` Value int `json:"value"` Unit string `json:"unit,omitempty"` } `json:"topBadges"` WaterUnit string `json:"waterUnit"` WaterUnitName string `json:"waterUnitName"` Weight float64 `json:"weight"` WeightUnit string `json:"weightUnit"` }
generated by json-to-go
type WeightLogs ¶
type WeightLogs struct {
Weight []Weight `json:"weight"`
}
func GetWeightLogs ¶
func GetWeightLogs(c *Client, param *WeightLogsParam) (*WeightLogs, error)
func GetWeightLogsContext ¶
func GetWeightLogsContext(ctx context.Context, c *Client, param *WeightLogsParam) (*WeightLogs, error)
type WeightLogsParam ¶
type WeightLogsParam struct { Date string `validate:"len=0|datetime=2006-01-02"` Period string `validate:"len=0|oneof=1d 7d 30d 1w 1m"` BaseDate string `validate:"len=0|datetime=2006-01-02"` EndDate string `validate:"len=0|datetime=2006-01-02"` }
GET https://api.fitbit.com/1/user/[user-id]/body/log/weight/date/[date].json GET https://api.fitbit.com/1/user/[user-id]/body/log/weight/date/[base-date]/[period].json GET https://api.fitbit.com/1/user/[user-id]/body/log/weight/date/[base-date]/[end-date].json