-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
98 lines (76 loc) · 2.33 KB
/
api.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
// LoginResponse represents the JSON response from an /android/user/sign_in request.
type LoginResponse struct {
Data struct {
Babies []struct {
Baby struct {
BabyID int64 `json:"baby_id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Birthday string `json:"birthday"` // "YYYY/MM/DD" format
} `json:"Baby"`
} `json:"babies"`
User struct {
AuthToken string `json:"encrypted_token"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
} `json:"user"`
} `json:"data"`
}
// PullResponse represents the JSON response from an /android/user/pull fetch.
type PullResponse struct {
Data struct {
Babies []struct {
BabyID int64 `json:"baby_id"`
SyncTime int64 `json:"sync_time"`
SyncToken string `json:"sync_token"`
BabyData struct {
Remove []BabyData `json:"remove"`
Update []BabyData `json:"update"`
} `json:"BabyData"`
BabyFeedData struct {
Remove []BabyFeedData `json:"remove"`
Update []BabyFeedData `json:"update"`
} `json:"BabyFeedData"`
// Other keys:
// "Baby" (static info about baby)
// "BabyFamily" (parent info)
// "BabyMilestone"
// "MilestonePhoto"
// "Photo"
// "UserBabyRelation"
} `json:"babies"`
// Other keys: "insights", "syncable_insights", "user"
} `json:"data"`
// Other keys: "rc" (response code? 0 on success)
}
type BabyData struct {
ID int64 `json:"id"`
BabyID int64 `json:"baby_id"`
StartTimestamp int64 `json:"start_timestamp"`
EndTimestamp *int64 `json:"end_timestamp"`
Key string `json:"key"` // e.g. "medicine", "sleep", "tummy"
// For key=diaper, val_int may have these values:
// 65536
// 66625
// 1089
// 1041
// 17
ValInt int64 `json:"val_int"`
// Used for key=temperature (ºC), or key=weight (kg), or key=height (cm)
ValFloat float32 `json:"val_float"`
// Used for key=medicine
ValStr string `json:"val_str"`
// "uuid"
}
type BabyFeedData struct {
ID int64 `json:"id"`
BabyID int64 `json:"baby_id"`
StartTimestamp int64 `json:"start_timestamp"`
FeedType int64 `json:"feed_type"` // e.g. 1
BreastUsed string `json:"breast_used"` // e.g. "R"
BreastLeft int64 `json:"breast_left_time"` // seconds
BreastRight int64 `json:"breast_right_time"` // seconds
BottleML float64 `json:"bottle_ml"`
// "uuid"
}