Skip to content

Commit feb4561

Browse files
committed
feat(TCX): Implement Activity TCX retrieval
Signed-off-by: Jo Vandeginste <Jo.Vandeginste@kuleuven.be>
1 parent 0180623 commit feb4561

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

activity.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,20 @@ func (c *Client) GetDailyActivitySummary(ctx context.Context, userID string, dat
152152
}
153153
return &dailyActivitySummary, rateLimit, b, nil
154154
}
155+
156+
// GetActivityTCX retrieves the details of a user's location and heart rate data during a logged exercise activity.
157+
//
158+
// Scope.Activity is required.
159+
//
160+
// Scope.Location is required.
161+
//
162+
// Web API Reference: https://dev.fitbit.com/build/reference/web-api/activity/get-activity-tcx/
163+
func (c *Client) GetActivityTCX(ctx context.Context, userID string, activityID int64, token *Token) ([]byte, *RateLimit, []byte, error) {
164+
endpoint := c.getEndpoint("GetActivityTCX", userID, activityID)
165+
b, rateLimit, err := c.getRequest(ctx, token, endpoint)
166+
if err != nil {
167+
return nil, nil, b, err
168+
}
169+
170+
return b, rateLimit, b, nil
171+
}

constant.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ const (
99
LowercaseAlphabetLetters = "abcdefghijklmnopqrstuvwxyz" // LowercaseAlphabetLetters is a set of lower case alphabetic characters
1010
)
1111

12-
var (
13-
apiEndpoints = map[string]string{
14-
"GetDailyActivitySummary": "/1/user/%s/activities/date/%s.json",
15-
"IntrospectToken": "/1.1/oauth2/introspect",
16-
"RevokeToken": "/oauth2/revoke",
17-
"GetWater": "/1/user/%s/foods/log/water/date/%s.json",
18-
"GetProfile": "/1/user/%s/profile.json",
19-
}
20-
)
12+
var apiEndpoints = map[string]string{
13+
"GetDailyActivitySummary": "/1/user/%s/activities/date/%s.json",
14+
"IntrospectToken": "/1.1/oauth2/introspect",
15+
"RevokeToken": "/oauth2/revoke",
16+
"GetWater": "/1/user/%s/foods/log/water/date/%s.json",
17+
"GetProfile": "/1/user/%s/profile.json",
18+
"GetActivityTCX": "/1/user/%s/activities/%d.tcx",
19+
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/anyappinc/fitbit
33
go 1.15
44

55
require (
6+
github.com/galeone/tcx v1.0.0 // indirect
67
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2
78
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
89
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
4444
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
4545
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
4646
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
47+
github.com/galeone/tcx v1.0.0 h1:rmSSL/+qDFWH+9YjoyU5mmm2R2tJUxvwr5nS+1Oq6sY=
48+
github.com/galeone/tcx v1.0.0/go.mod h1:cHrVurc4epPGjwvJt8kDkQgp4hEUhk0UiWPSN6/dykI=
4749
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
4850
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
4951
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -103,6 +105,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
103105
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
104106
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
105107
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
108+
github.com/philhofer/vec v0.0.0-20140421144027-536fc796d369 h1:3tLX6+/o9lWIdsG4AIHZKgd/qTP6auJASIV434u/WTI=
109+
github.com/philhofer/vec v0.0.0-20140421144027-536fc796d369/go.mod h1:VGTjob2K0ciQ6Ad9+wH9rLOQbmYZFlKh9Ma4yqRW3bo=
106110
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
107111
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
108112
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=

0 commit comments

Comments
 (0)