healthmate

package
v0.0.0-...-09065da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultScopes is describes all available Health Mate scopes.
	// Needs to be comma separated for the Health Mate endpoint and slice of string
	// for Oauth2 package.
	DefaultScopes = []string{"user.info,user.metrics,user.activity,user.sleepevents"}

	// HealthMateState is a random state for generating auth code url to mitigate CSRF attacks.
	HealthMateState string
)
View Source
var HealthMateEndpoint = oauth2.Endpoint{
	AuthURL:  "https://account.withings.com/oauth2_user/authorize2",
	TokenURL: "https://account.withings.com/oauth2/token",
}

HealthMateEndpoint is the endpoints for Withings Health Mate

Functions

func NewClient

func NewClient(clientID, clientSecret, redirectURL string) api.ApiClient

NewClient instantiates a new client to interact with the Health Mate API. Please refer to the official Withings documentation to obtain the required parameters

Types

type Client

type Client api.Client // allow receivers on shared Client definition

func (*Client) GetAccessToken

func (c *Client) GetAccessToken(code string) (token *oauth2.Token, err error)

GetAccessToken obtains the access token for the authenticated user

func (*Client) GetAuthCodeURL

func (c *Client) GetAuthCodeURL() string

GetAuthCodeURL obtains the user authentication URL

func (Client) ProcessRequest

func (hc Client) ProcessRequest(payload url.Values, v interface{}) error

type Measure

type Measure struct {
	Value       int64 `json:"value"`
	Type        int64 `json:"type"`
	Unit        int64 `json:"unit"`
	Date        Timestamp
	Grpid       int64
	AttributeID int64
}

func (Measure) Export

func (s Measure) Export() (interface{}, error)

func (Measure) String

func (s Measure) String() string

type MeasureResult

type MeasureResult struct {
	Status int64 `json:"status"`
	Body   struct {
		Updatetime  Timestamp `json:"updatetime"`
		Timezone    string    `json:"timezone"`
		Measuregrps []struct {
			Grpid        int64     `json:"grpid"`
			Attrib       int64     `json:"attrib"`
			Date         Timestamp `json:"date"`
			Created      Timestamp `json:"created"`
			Category     int64     `json:"category"`
			Deviceid     string    `json:"deviceid"`
			HashDeviceid string    `json:"hash_deviceid"`
			Measures     []Measure `json:"measures"`
			Comment      string    `json:"comment"`
		} `json:"measuregrps"`
	} `json:"body"`
}

type Series

type Series struct {
	ID        int64     `json:"id"`
	Category  int64     `json:"category"`
	Timezone  string    `json:"timezone"`
	Model     int64     `json:"model"`
	Attrib    int64     `json:"attrib"`
	Startdate Timestamp `json:"startdate"`
	Enddate   Timestamp `json:"enddate"`
	Date      string    `json:"date"`
	Deviceid  string    `json:"deviceid"`
	Workout   struct {
		Calories       float64 `json:"calories"`
		Effduration    float64 `json:"effduration"`
		Intensity      int64   `json:"intensity"`
		ManualDistance float64 `json:"manual_distance"`
		ManualCalories float64 `json:"manual_calories"`
		Steps          int64   `json:"steps"`
		Distance       float64 `json:"distance"`
		Elevation      float64 `json:"elevation"`
		HRAverage      int64   `json:"hr_average"`
		HRMin          int64   `json:"hr_min"`
		HRMax          int64   `json:"hr_max"`
	} `json:"data"`
	Modified int64 `json:"modified"`
}

func (Series) Export

func (s Series) Export() (interface{}, error)

func (Series) String

func (s Series) String() string

type Timestamp

type Timestamp time.Time

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

func (Timestamp) String

func (t Timestamp) String() string

String returns t as a formatted string

func (Timestamp) Time

func (t Timestamp) Time() time.Time

Time returns the JSON time as a time.Time instance in UTC

func (Timestamp) Unix

func (t Timestamp) Unix() int64

Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC. The result does not depend on the location associated with t.

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(s []byte) (err error)

type WorkoutResult

type WorkoutResult struct {
	Status int64 `json:"status"`
	Body   struct {
		Series []Series `json:"series"`
		More   bool     `json:"more"`
		Offset int64    `json:"offset"`
	} `json:"body"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL