}, nil
}
-func (c *Client) ActivitySummary(t time.Time) (*ActivitySummary, error) {
+func (c *Client) ActivitySummary(ctx context.Context, t time.Time) (*ActivitySummary, error) {
url := fmt.Sprintf("https://api.fitbit.com/1/user/%s/activities/date/%s.json",
c.fitbitUserID, t.Format("2006-01-02"))
}
defer res.Body.Close()
+ data, _ := ioutil.ReadAll(res.Body)
+ log.Debugf(ctx, "GET %s -> %s", url, data)
+
var summary ActivitySummary
- if err := json.NewDecoder(res.Body).Decode(&summary); err != nil {
+ if err := json.Unmarshal(data, &summary); err != nil {
return nil, err
}
return err
}
- summary, err := fitbitClient.ActivitySummary(tm)
+ summary, err := fitbitClient.ActivitySummary(ctx, tm)
if err != nil {
return err
}