|
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
|
4 |
|
public function find(string $leagueId): array |
|
15
|
|
|
{ |
|
16
|
4 |
|
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
|
1 |
|
public function matchups(string $leagueId, string $week): array |
|
41
|
|
|
{ |
|
42
|
1 |
|
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
|
1 |
|
public function rosters(string $leagueId): array |
|
74
|
|
|
{ |
|
75
|
1 |
|
return $this->get('league/' . $leagueId . '/rosters'); |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @param string $leagueId |
|
80
|
|
|
* @return array|[] |
|
|
|
|
|
|
81
|
|
|
* @throws ClientException if status code <> 200 |
|
82
|
|
|
* @throws Exception if response body equals null |
|
83
|
|
|
*/ |
|
84
|
|
|
public function winnersBracket(string $leagueId): array |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->get('league/' . $leagueId . '/winners_bracket'); |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param string $leagueId |
|
91
|
|
|
* @return array|[] |
|
|
|
|
|
|
92
|
|
|
* @throws ClientException if status code <> 200 |
|
93
|
|
|
* @throws Exception if response body equals null |
|
94
|
|
|
*/ |
|
95
|
|
|
public function losersBracket(string $leagueId): array |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->get('league/' . $leagueId . '/losers_bracket'); |
|
|
|
|
|
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
} |
|
101
|
|
|
|