Package gfit: Create the "activity segment" data source.
authorFlorian Forster <ff@octo.it>
Sun, 28 Jan 2018 19:57:57 +0000 (20:57 +0100)
committerFlorian Forster <ff@octo.it>
Sun, 28 Jan 2018 19:57:57 +0000 (20:57 +0100)
gfit/gfit.go

index 227f463..657da7d 100644 (file)
@@ -234,12 +234,22 @@ func (c *Client) SetActivities(ctx context.Context, activities []Activity, start
                return nil
        }
 
-       dataStreamID := DataStreamID(&fitness.DataSource{
+       dataStreamID, err := c.DataSourceCreate(ctx, &fitness.DataSource{
+               Application: Application(ctx),
                DataType: &fitness.DataType{
+                       Field: []*fitness.DataTypeField{
+                               &fitness.DataTypeField{
+                                       Name:   "activity",
+                                       Format: "integer",
+                               },
+                       },
                        Name: dataTypeNameActivitySegment,
                },
                Type: "raw",
        })
+       if err != nil {
+               return err
+       }
 
        endOfDay := startOfDay.Add(24 * time.Hour).Add(-1 * time.Nanosecond)