Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Fitbit.Portable/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal class Constants
public const string TemporaryCredentialsAccessTokenUri = "oauth/access_token";
public const string AuthorizeUri = "oauth/authorize";
public const string LogoutAndAuthorizeUri = "oauth/logout_and_authorize";
public const string FloorsUnsupportedOnDeviceError = "Invalid time series resource path: /activities/floors";

public class Headers
{
Expand Down
30 changes: 23 additions & 7 deletions Fitbit.Portable/FitbitClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,37 @@ public async Task<IntradayData> GetIntraDayTimeSeriesAsync(IntradayResourceType
dayAndStartTime.Day == dayAndStartTime.Add(intraDayTimeSpan).Day) //adding the timespan doesn't go in to the next day
{
apiCall = string.Format("/1/user/-{0}/date/{1}/1d/time/{2}/{3}.json",
timeSeriesResourceType.GetStringValue(),
dayAndStartTime.ToFitbitFormat(),
dayAndStartTime.ToString("HH:mm"),
dayAndStartTime.Add(intraDayTimeSpan).ToString("HH:mm"));
timeSeriesResourceType.GetStringValue(),
dayAndStartTime.ToFitbitFormat(),
dayAndStartTime.ToString("HH:mm"),
dayAndStartTime.Add(intraDayTimeSpan).ToString("HH:mm"));
}
else //just get the today data, there was a date specified but the timerange was likely too large or negative
{
apiCall = string.Format("/1/user/-{0}/date/{1}/1d.json",
timeSeriesResourceType.GetStringValue(),
dayAndStartTime.ToFitbitFormat());
timeSeriesResourceType.GetStringValue(),
dayAndStartTime.ToFitbitFormat());
}

apiCall = FitbitClientHelperExtensions.ToFullUrl(apiCall);

HttpResponseMessage response = await HttpClient.GetAsync(apiCall);
HttpResponseMessage response = null;
try
{
response = await HttpClient.GetAsync(apiCall);
}
catch (FitbitRequestException fre)
{
if (fre.ApiErrors.Any(err => err.Message == Constants.FloorsUnsupportedOnDeviceError))
{
return null;
}
else
{
//otherwise, rethrow because we only want to alter behavior for the very specific case above
throw;
}
}
await HandleResponse(response);
string responseBody = await response.Content.ReadAsStringAsync();

Expand Down