-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathactivity_lifetime.go
69 lines (64 loc) · 1.84 KB
/
activity_lifetime.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package fitbit
import "encoding/json"
// ActivitiesLifetime contains the account lifetime statistics
type ActivitiesLifetime struct {
Best struct {
Total struct {
Distance struct {
Date string `json:"date"`
Value float64 `json:"value"`
} `json:"distance"`
Floors struct {
Date string `json:"date"`
Value float64 `json:"value"`
} `json:"floors"`
Steps struct {
Date string `json:"date"`
Value int64 `json:"value"`
} `json:"steps"`
} `json:"total"`
Tracker struct {
Distance struct {
Date string `json:"date"`
Value float64 `json:"value"`
} `json:"distance"`
Floors struct {
Date string `json:"date"`
Value float64 `json:"value"`
} `json:"floors"`
Steps struct {
Date string `json:"date"`
Value int64 `json:"value"`
} `json:"steps"`
} `json:"tracker"`
} `json:"best"`
Lifetime struct {
Total struct {
ActiveScore float64 `json:"activeScore"`
CaloriesOut float64 `json:"caloriesOut"`
Distance float64 `json:"distance"`
Floors int64 `json:"floors"`
Steps int64 `json:"steps"`
} `json:"total"`
Tracker struct {
ActiveScore float64 `json:"activeScore"`
CaloriesOut float64 `json:"caloriesOut"`
Distance float64 `json:"distance"`
Floors int64 `json:"floors"`
Steps int64 `json:"steps"`
} `json:"tracker"`
} `json:"lifetime"`
}
// ActivitiesLifetime returns the summary of activities and made exercises
// date must be in the format yyyy-MM-dd
func (m *Session) ActivitiesLifetime() (ActivitiesLifetime, error) {
contents, err := m.makeRequest("https://api.fitbit.com/1/user/-/activities.json")
if err != nil {
return ActivitiesLifetime{}, err
}
summary := ActivitiesLifetime{}
if err := json.Unmarshal(contents, &summary); err != nil {
return ActivitiesLifetime{}, err
}
return summary, nil
}