public async Task <FitbitResponse <HeartActivitiesTimeSeries> > GetHeartRateTimeSeries(DateTime date, DateRangePeriod dateRangePeriod, string userId = null) { if (string.IsNullOrWhiteSpace(userId)) { userId = "-"; } string apiCall = String.Format("https://api.fitbit.com/1.1/user/{0}/activities/heart/date/{1}/{2}.json", userId, date.ToString("yyyy-MM-dd"), dateRangePeriod.GetStringValue()); HttpResponseMessage response = await HttpClient.GetAsync(apiCall); var fitbitResponse = await HandleResponse <HeartActivitiesTimeSeries>(response); if (fitbitResponse.Success) { string responseBody = await response.Content.ReadAsStringAsync(); var seralizer = new JsonDotNetSerializer(); fitbitResponse.Data = seralizer.GetHeartActivitiesTimeSeries(responseBody); } return(fitbitResponse); }
public Fat GetFat(DateTime startDate, DateRangePeriod period) { if (period != DateRangePeriod.OneDay && period != DateRangePeriod.OneWeek && period != DateRangePeriod.ThirtyDays && period != DateRangePeriod.OneMonth) throw new Exception("This API endpoint only supports range up to 31 days. See https://wiki.fitbit.com/display/API/API-Get-Body-Fat"); string apiCall = String.Format("/1/user/-/body/log/fat/date/{0}/{1}.xml", startDate.ToString("yyyy-MM-dd"), period.GetStringValue()); RestRequest request = new RestRequest(apiCall); request.RootElement = "fat"; var response = restClient.Execute<Fitbit.Models.Fat>(request); HandleResponse(response); return response.Data; }
public TimeSeriesDataListInt GetTimeSeriesInt(TimeSeriesResourceType timeSeriesResourceType, DateTime endDate, DateRangePeriod period, string userId) { return GetTimeSeriesInt(timeSeriesResourceType, endDate, period.GetStringValue(), userId); }
/// <summary> /// Get Fat for a period of time starting at date. /// </summary> /// <param name="startDate"></param> /// <param name="period"></param> /// <returns></returns> public async Task <FitbitResponse <Weight> > GetWeightAsync(DateTime startDate, DateRangePeriod period) { switch (period) { case DateRangePeriod.OneDay: case DateRangePeriod.SevenDays: case DateRangePeriod.OneWeek: case DateRangePeriod.ThirtyDays: case DateRangePeriod.OneMonth: break; default: throw new Exception("This API endpoint only supports range up to 31 days. See https://wiki.fitbit.com/display/API/API-Get-Body-Weight"); } string apiCall = FitbitClientHelperExtensions.ToFullUrl("/1/user/{0}/body/log/weight/date/{1}/{2}.json", args: new object[] { startDate.ToFitbitFormat(), period.GetStringValue() }); HttpResponseMessage response = await HttpClient.GetAsync(apiCall); var fitbitResponse = await HandleResponse <Weight>(response); if (fitbitResponse.Success) { string responseBody = await response.Content.ReadAsStringAsync(); var seralizer = new JsonDotNetSerializer(); fitbitResponse.Data = seralizer.GetWeight(responseBody); } return(fitbitResponse); }
/// <summary> /// Requests the specified <see cref="TimeSeriesResourceType"/> for the date range and user specified /// </summary> /// <param name="timeSeriesResourceType"></param> /// <param name="endDate"></param> /// <param name="period"></param> /// <param name="encodedUserId"></param> /// <returns></returns> public Task <FitbitResponse <TimeSeriesDataListInt> > GetTimeSeriesIntAsync(TimeSeriesResourceType timeSeriesResourceType, DateTime endDate, DateRangePeriod period, string encodedUserId = null) { return(GetTimeSeriesIntAsync(timeSeriesResourceType, endDate, period.GetStringValue(), encodedUserId)); }
/// <summary> /// Requests the specified <see cref="TimeSeriesResourceType"/> for the date range and user specified /// </summary> /// <param name="timeSeriesResourceType"></param> /// <param name="endDate"></param> /// <param name="period"></param> /// <param name="encodedUserId"></param> /// <returns></returns> public async Task <FitbitResponse <TimeSeriesDataList> > GetTimeSeriesAsync(TimeSeriesResourceType timeSeriesResourceType, DateTime endDate, DateRangePeriod period, string encodedUserId = default(string)) { return(await GetTimeSeriesAsync(timeSeriesResourceType, endDate, period.GetStringValue(), encodedUserId)); }
public TimeSeriesDataListInt GetTimeSeriesInt(TimeSeriesResourceType timeSeriesResourceType, DateTime endDate, DateRangePeriod period, string userId) { return(GetTimeSeriesInt(timeSeriesResourceType, endDate, period.GetStringValue(), userId)); }
public Fat GetFat(DateTime startDate, DateRangePeriod period) { if (period != DateRangePeriod.OneDay && period != DateRangePeriod.OneWeek && period != DateRangePeriod.ThirtyDays && period != DateRangePeriod.OneMonth) { throw new Exception("This API endpoint only supports range up to 31 days. See https://wiki.fitbit.com/display/API/API-Get-Body-Fat"); } string apiCall = String.Format("/1/user/-/body/log/fat/date/{0}/{1}.xml", startDate.ToString("yyyy-MM-dd"), period.GetStringValue()); RestRequest request = new RestRequest(apiCall); request.RootElement = "fat"; var response = restClient.Execute <Fitbit.Models.Fat>(request); HandleResponse(response); return(response.Data); }