1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SchoppAx\Sleeper\Api; |
4
|
|
|
|
5
|
|
|
class Leagues extends Api |
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @param string $leagueId |
10
|
|
|
* @return array|[] |
|
|
|
|
11
|
|
|
* @throws ClientException if status code <> 200 |
12
|
|
|
* @throws Exception if response body equals null |
13
|
|
|
*/ |
14
|
2 |
|
public function find(string $leagueId): array |
15
|
|
|
{ |
16
|
2 |
|
return $this->get('league/' . $leagueId); |
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param string $userId |
21
|
|
|
* @param string $season |
22
|
|
|
* @param string[optional] $sport default is nfl |
23
|
|
|
* @return array|[] |
|
|
|
|
24
|
|
|
* @throws ClientException if status code <> 200 |
25
|
|
|
* @throws Exception if response body equals null |
26
|
|
|
*/ |
27
|
1 |
|
public function byUser(string $userId, string $season, string $sport = 'nfl'): array |
28
|
|
|
{ |
29
|
1 |
|
return $this->get('user/' . $userId . '/leagues/'. $sport .'/' . $season); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param string $leagueId |
35
|
|
|
* @param string $week |
36
|
|
|
* @return array|[] |
|
|
|
|
37
|
|
|
* @throws ClientException if status code <> 200 |
38
|
|
|
* @throws Exception if response body equals null |
39
|
|
|
*/ |
40
|
|
|
public function matchups(string $userId, string $week): array |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
return $this->get('league/' . $leagueId . '/matchups/' . $week); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string[optional] $sport default is nfl |
47
|
|
|
* @return object |
48
|
|
|
* @throws ClientException if status code <> 200 |
49
|
|
|
* @throws Exception if response body equals null |
50
|
|
|
*/ |
51
|
1 |
|
public function state(string $sport = 'nfl'): array |
52
|
|
|
{ |
53
|
1 |
|
return $this->get('state/'. $sport); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $leagueId |
58
|
|
|
* @return array|[] |
|
|
|
|
59
|
|
|
* @throws ClientException if status code <> 200 |
60
|
|
|
* @throws Exception if response body equals null |
61
|
|
|
*/ |
62
|
1 |
|
public function users(string $leagueId): array |
63
|
|
|
{ |
64
|
1 |
|
return $this->get('league/' . $leagueId . '/users'); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param string $leagueId |
69
|
|
|
* @return array|[] |
|
|
|
|
70
|
|
|
* @throws ClientException if status code <> 200 |
71
|
|
|
* @throws Exception if response body equals null |
72
|
|
|
*/ |
73
|
|
|
public function rosters(string $leagueId): array |
74
|
|
|
{ |
75
|
|
|
return $this->get('league/' . $leagueId . '/rosters'); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|