From 246b00f84f83100342ee8d57f1faf17ac5d0dd41 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 22 Jan 2018 09:04:48 +0100 Subject: [PATCH] Package fitbit: ActivitySummery(): Log full response. --- fitbit/fitbit.go | 7 +++++-- gfitsync.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fitbit/fitbit.go b/fitbit/fitbit.go index 2c0a04a..414ea37 100644 --- a/fitbit/fitbit.go +++ b/fitbit/fitbit.go @@ -145,7 +145,7 @@ func NewClient(ctx context.Context, fitbitUserID string, u *app.User) (*Client, }, 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")) @@ -155,8 +155,11 @@ func (c *Client) ActivitySummary(t time.Time) (*ActivitySummary, error) { } 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 } diff --git a/gfitsync.go b/gfitsync.go index 4ff1bab..65cbfa6 100644 --- a/gfitsync.go +++ b/gfitsync.go @@ -240,7 +240,7 @@ func handleNotification(ctx context.Context, s *fitbit.Subscription) error { return err } - summary, err := fitbitClient.ActivitySummary(tm) + summary, err := fitbitClient.ActivitySummary(ctx, tm) if err != nil { return err } -- 2.11.0