From 73954feba65c75b2fe29c737e22ec6dc282fe75b Mon Sep 17 00:00:00 2001 From: Patrick Bogen Date: Wed, 14 Feb 2018 23:44:56 -0800 Subject: [PATCH 1/3] fix small typos --- README.md | 20 ++++++++++---------- godoc.go | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b818120..8fdbd21 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,16 @@ This is a go client that allows easy access to the Nokia Health API (https://dev **NOTICE** - Looking for users with data from various withings devices. Currently only testing against an account with a withings scale. The API documentation is very sketchy and testing against real data may find more issues. -## Oauth Notes +## OAuth Notes -The Nokia Health OAuth implemenation required some modifcations resulting in a fork of dghubble/oauth1. This project relies on the fork located at jrmycanady/oauth1. +The Nokia Health OAuth implemenation required some modifications resulting in a fork of dghubble/oauth1. This project relies on the fork located at jrmycanady/oauth1. ## Supported Resources (Currently all in the public API docs.) * User Access Requests * Retrieving user body measurements -* Retrieve activity measurments +* Retrieve activity measurements * Retrieve workouts -* Retreive intraday activities - Apparently requires additional authorization wich I don't have yet so no testing. +* Retreive intraday activities - Apparently requires additional authorization which I don't have yet so no testing. * Retrieve sleep measures - Limited testing so report any issues. * Retrieve sleep summary - Limited testing so report any issues. * Creating a notification @@ -33,7 +33,7 @@ Once that is complete, you will need to request a token for the user. If you are ### User Authorization -Oauth1 has a multi step request process to generate a token for the end user. Details around this can be found [here](https://developer.health.nokia.com/api) as well as general searching. A short example is show below but for further information see the [godcos](https://godoc.org/github.com/jrmycanady/nokiahealth) +OAuth 1.0 has a multi step request process to generate a token for the end user. Details around this can be found [here](https://developer.health.nokia.com/api) as well as general searching. A short example is show below but for further information see the [godcos](https://godoc.org/github.com/jrmycanady/nokiahealth) 1. Generate end-user authorization url and provide it to the end user to click on. This URL is encoded in such a way that Nokia knows the user is requesting to give your develper account access to theirs. @@ -47,7 +47,7 @@ if err != nil { fmt.Println(ar.AuthorizationURL) ``` -2. If you provided a callback URL nokia will then redirect them to that URL with queyr parameters set containing the verfier string and userid. Otherwise if it's empty the user will see it on screen and would need to copy and paste it into your app. Once you have those two bits of info, it's time to get the token. +2. If you provided a callback URL nokia will then redirect them to that URL with query parameters set containing the verifier string and userid. Otherwise if it's empty the user will see it on screen and would need to copy and paste it into your app. Once you have those two bits of info, it's time to get the token. ```go u, err := ar.GenerateUser("", ) if err != nil { @@ -55,7 +55,7 @@ if err != nil { } ``` 3. If all has gone well you now have a user object you may use to query. Methods off the user object include things like GetBodyMeasure() -4. Save the UseriD, AccessTokenStr and AccessSecretStr for later requets. +4. Save the UserID, AccessTokenStr and AccessSecretStr for later requests. ### User Requests @@ -74,7 +74,7 @@ m, err := u.GetBodyMeasures(nil) ## Making Requests -Requests are performed from methods on the User. Each request accepts a specific query struct with the details for the request. For example: +Requests are performed from methods on the User. Each request accepts a specific query struct with the details for the request. For example: ```go p := nokiahealth.BodyMeasuresQueryParams{} @@ -84,8 +84,8 @@ p.StartDate = &t m, err := u.GetBodyMeasures(&p) ``` -In most cases the response will contain all the information you need. Some methods provide additional optional processing that can provide a more usable form to the data. GetBodyMeasures is one of these methods. It's recommended to read the [docs](https://godoc.org/github.com/jrmycanady/nokiahealth) for each method to see how best to use them. +In most cases the response will contain all the information you need. Some methods provide additional optional processing that can provide a more usable form to the data. GetBodyMeasures is one of these methods. It's recommended to read the [docs](https://godoc.org/github.com/jrmycanady/nokiahealth) for each method to see how best to use them. ```go measures := m.ParseData() -``` \ No newline at end of file +``` diff --git a/godoc.go b/godoc.go index bbfb06a..009abc7 100644 --- a/godoc.go +++ b/godoc.go @@ -1,14 +1,14 @@ // Package nokiahealth is a client library for for working with the Nokia // Health (Withings) API. It includes support for all resources listed on the public // api documentation at https://developer.health.nokia.com/api/doc. This -// includes everything from user access token generation to retreiving -// body measurments and setting up notifications. +// includes everything from user access token generation to retrieving +// body measurements and setting up notifications. // // Due to limited access of Nokia Health devices, testing of each // resource has been limited. If you have access to more data or run into // any bugs/missing features, please place an issue on github at // https://github.com/jrmycanady/nokiahealth. The API documentation has been -// found to be severly lacking or compeltely incorrect so oddities are +// found to be severly lacking or completely incorrect so oddities are // expected to be found. Most are easily fixed as long as the raw request data // can be provided. // @@ -41,9 +41,9 @@ // client := nokiahealth.NewClient("consumer_key","consumer_secret", "callback_url") // The client can be used to handle user authorization as well as generate // user structs from stores user authorization tokens. Details of that can be -// found in the authorization section. The following is an examle of creating +// found in the authorization section. The following is an example of creating // a user from known tokens and secrets. All three parameters are required as -// the API doesn't rely on just the user_tokent to identify the user. +// the API doesn't rely on just the user_token to identify the user. // user := client.GenerateUser("user_token", "user_secret", "user_id") // With the user defined API calls can be made by utilizing on of the methods // for the User struct. i.e. @@ -54,7 +54,7 @@ // and how to use these parameters. https://developer.health.nokia.com/api/doc. // Each param type is specific to the request type. // -// Each method varies somewhat in the foramt it returns due to the inconsistencies +// Each method varies somewhat in the format it returns due to the inconsistencies // in the Nokia Health API. This package does what it can to work around // these inconsistencies but you should refer to the documentation for each // method for more information. The one commonality is that the package does @@ -100,10 +100,10 @@ // a different process or the original access request struct is not available. // In such a case the generate user cannot be used which means you cannot // obtain the secret. In those cases you can rebuild an access request token -// using the RebuildAccessReuqest() method of the client. This still requires +// using the RebuildAccessRequest() method of the client. This still requires // storing the access request token and secret somewhere. Both of which are // public fields on the AccessRequest struct. -// ar := client.RebuildAccessReuqest("token", "secret") +// ar := client.RebuildAccessRequest("token", "secret") // // Debug / Testing Client Options // From 431dddfccee51305e0ed21e6a542ece5e4ae6da5 Mon Sep 17 00:00:00 2001 From: Patrick Bogen Date: Wed, 14 Feb 2018 23:46:53 -0800 Subject: [PATCH 2/3] fix some issues noted by go vet --- types.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types.go b/types.go index a128ef8..8d1bba7 100644 --- a/types.go +++ b/types.go @@ -163,7 +163,7 @@ type SleepSummaryData struct { REMSleepDuration *int `json:"remsleepduration"` WakeUpCount int `json:"wakeupcount"` DurationToSleep int `json:"durationtosleep"` - DurationToWakeUp *int `json:"durationtowakeup` + DurationToWakeUp *int `json:"durationtowakeup"` } // SleepMeasuresResp represents the unmarshelled api response for sleep measures. @@ -290,7 +290,7 @@ type ActivitiesMeasuresResp struct { // body. As such they are all pointers. You may check SingleValue to determine // if a single value was provided. type ActivitiesMeasuresRespBody struct { - ParsedDate *time.Time `json:"parseddate` + ParsedDate *time.Time `json:"parseddate"` Date *string `json:"date"` Steps *float64 `json:"steps"` Distance *float64 `json:"distance"` @@ -308,7 +308,7 @@ type ActivitiesMeasuresRespBody struct { // Activity represents an activity as recorded by Nokia Health. type Activity struct { - ParsedDate *time.Time `json:"parseddate` + ParsedDate *time.Time `json:"parseddate"` Date string `json:"date"` Steps float64 `json:"steps"` Distance float64 `json:"distance"` @@ -334,7 +334,7 @@ type BodyMeasuresQueryParams struct { MeasType *meastype.MeasType `json:"meastype"` Category *int `json:"category"` Limit *int `json:"limit"` - Offset *int `json:'offset"` + Offset *int `json:"offset"` ParseResponse bool } From e39e5cd210112cbd71be50922651ad7778076a8d Mon Sep 17 00:00:00 2001 From: Patrick Bogen Date: Wed, 14 Feb 2018 23:47:03 -0800 Subject: [PATCH 3/3] fix null pointer dereference --- nokiahealth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nokiahealth.go b/nokiahealth.go index 86c1aaf..21fb96f 100644 --- a/nokiahealth.go +++ b/nokiahealth.go @@ -406,7 +406,7 @@ func (u User) GetBodyMeasures(params *BodyMeasuresQueryParams) (BodyMeasuresResp return bodyMeasureResponse, err } - if params.ParseResponse { + if params != nil && params.ParseResponse { bodyMeasureResponse.ParsedResponse = bodyMeasureResponse.ParseData() }