-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.go
62 lines (48 loc) · 1.75 KB
/
stats.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
package sleeper
import (
"fmt"
)
// StatsService deals with interacting with the Stats segment of the Sleeper API
type StatsService struct {
client *Client
}
// GetAllStats gets all stats
func (statsService *StatsService) GetAllStats(sport, seasonType, season string) (*ObjectResponse, error) {
path := fmt.Sprintf("stats/%s/%s/%s", sport, seasonType, season)
req, err := statsService.client.newRequest("GET", path)
if err != nil {
return nil, err
}
resp, err := statsService.client.doWithObjectResponse(req)
return resp, err
}
// GetStatsForWeek gets stats for a given week
func (statsService *StatsService) GetStatsForWeek(sport, seasonType, season, week string) (*ObjectResponse, error) {
path := fmt.Sprintf("stats/%s/%s/%s/%s", sport, seasonType, season, week)
req, err := statsService.client.newRequest("GET", path)
if err != nil {
return nil, err
}
resp, err := statsService.client.doWithObjectResponse(req)
return resp, err
}
// GetAllProjections gets all stats
func (statsService *StatsService) GetAllProjections(sport, seasonType, season string) (*ObjectResponse, error) {
path := fmt.Sprintf("projections/%s/%s/%s", sport, seasonType, season)
req, err := statsService.client.newRequest("GET", path)
if err != nil {
return nil, err
}
resp, err := statsService.client.doWithObjectResponse(req)
return resp, err
}
// GetProjectionsForWeek gets stats for a given week
func (statsService *StatsService) GetProjectionsForWeek(sport, seasonType, season, week string) (*ObjectResponse, error) {
path := fmt.Sprintf("projections/%s/%s/%s/%s", sport, seasonType, season, week)
req, err := statsService.client.newRequest("GET", path)
if err != nil {
return nil, err
}
resp, err := statsService.client.doWithObjectResponse(req)
return resp, err
}