Skip to content

add IsNullOrWhiteSpace guard for userId param of GetHeartRateTimeSeri…#235

Merged
aarondcoleman merged 2 commits into
masterfrom
issue234-getHeartRateTimeSeriesNullGuard
Oct 19, 2017
Merged

add IsNullOrWhiteSpace guard for userId param of GetHeartRateTimeSeri…#235
aarondcoleman merged 2 commits into
masterfrom
issue234-getHeartRateTimeSeriesNullGuard

Conversation

@joshfitabase

@joshfitabase joshfitabase commented Oct 17, 2017

Copy link
Copy Markdown
Contributor

…es()

This prevents errors in HttpClient if the URL is malformed by omission of userId resulting in user//activities. In this case, the current version of HttpClient exhibits the behvior of switching from https to http (causing a fitbit error)

fixes #235

…es()

This prevents errors in HttpClient if the URL is malformed by omission of userId resulting in user//activities. In this case, the current version of HttpClient exhibits the behvior of switching from https to http (causing a fitbit error)

@WestDiscGolf WestDiscGolf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other methods use the helper, as mentioned in the comment. This should not then require another isnull check on the userid :-)

Comment thread Fitbit.Portable/FitbitClient.cs Outdated
userId = "-";
}

string path = $"1.1/user/{userId}/activities/heart/date/{date:yyyy-MM-dd}/{dateRangePeriod.GetStringValue()}.json";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks like it was needed because the path isn't being built up using the FitbitClientHelperExtensions.ToFullUrl which does this check for the userId. Example below from GetActivitiesStatsAsync ...

        public async Task<ActivitiesStats> GetActivitiesStatsAsync(string encodedUserId = null)
        {
            string apiCall = FitbitClientHelperExtensions.ToFullUrl("/1/user/{0}/activities.json", encodedUserId);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me Adam! Dwayne and I actually had a brief conversation along the lines of "there really should be a helper..." but this was a quick in & out job for me yesterday so I missed it. I'll fix the PR today to leverage the helper instead, thanks!

@dwaynefitabase dwaynefitabase Oct 18, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better documentation may help contributors to understand what needs to be passed in.

        /// Converts the REST api resource into the fully qualified url
        /// </summary>
        /// <param name="apiCall">
             ///"Format String" with one "Format Item" as a placeholder for "UserId"
        ///</param>
        /// <param name="encodedUserId"></param>
        /// <param name="args"></param>
        /// <returns>Fully qualified url</returns>```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! :-)

…Extensions.ToFullUrl(). Add better documentation on ToFullUrl()
@aarondcoleman
aarondcoleman merged commit dd02228 into master Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants