return nil
}
+func (c *Client) Unsubscribe(ctx context.Context) error {
+ subscriberID, err := c.appUser.ID(ctx)
+ if err != nil {
+ return err
+ }
+
+ url := fmt.Sprintf("https://api.fitbit.com/1/user/%s/apiSubscriptions/%s.json",
+ c.fitbitUserID, subscriberID)
+ req, err := http.NewRequest(http.MethodDelete, url, nil)
+ if err != nil {
+ return err
+ }
+
+ res, err := c.client.Do(req.WithContext(ctx))
+ if err != nil {
+ return err
+ }
+ defer res.Body.Close()
+
+ if res.StatusCode >= 400 && res.StatusCode != http.StatusConflict {
+ data, _ := ioutil.ReadAll(res.Body)
+ log.Errorf(ctx, "creating subscription failed: status %d %q", res.StatusCode, data)
+ return fmt.Errorf("deleting subscription failed")
+ }
+
+ return nil
+}
+
+func (c *Client) DeleteToken(ctx context.Context) error {
+ return c.appUser.DeleteToken(ctx, "Fitbit")
+}
+
type Profile struct {
Name string
Timezone *time.Location