-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
latest.go
27 lines (22 loc) · 624 Bytes
/
latest.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
package gocorona
import (
"context"
)
// Latest holds fields related to latest data
type Latest struct {
Confirmed int `json:"confirmed"`
Deaths int `json:"deaths"`
Recovered int `json:"recovered"`
}
// LatestData holds response from the endpoint /v2/latest
type LatestData struct {
Data Latest `json:"latest"`
}
// GetLatestData returns total amonut confirmed cases, deaths, and recoveries.
func (c Client) GetLatestData(ctx context.Context) (data LatestData, err error) {
endpoint := "/latest"
if err := c.makeGetRequest(ctx, endpoint, &data); err != nil {
return LatestData{}, err
}
return data, nil
}