-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsleep.go
31 lines (27 loc) · 944 Bytes
/
sleep.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
package runalyze
import (
"context"
"net/http"
"time"
)
// Sleep represents the data of a sleep entry
type Sleep struct {
DateTime time.Time `json:"date_time"`
Duration int `json:"duration"`
RemDuration int `json:"rem_duration,omitempty"`
LightSleepDuration int `json:"light_sleep_duration,omitempty"`
DeepSleepDuration int `json:"deep_sleep_duration,omitempty"`
AwakeDuration int `json:"awake_duration,omitempty"`
HrAverage int `json:"hr_average,omitempty"`
HrLowest int `json:"hr_lowest,omitempty"`
Quality int `json:"quality,omitempty"`
}
// CreateSleep creates a new sleeping entry
func (c *Client) CreateSleep(ctx context.Context, s Sleep) (*http.Response, error) {
req, err := c.NewRequest("POST", "metrics/sleep", s)
if err != nil {
return nil, err
}
resp, err := c.Do(ctx, req, nil)
return resp, err
}