@@ 16-50 (lines=35) @@ | ||
13 | * @homepage https://github.com/jofner/Twitch-SDK |
|
14 | */ |
|
15 | ||
16 | class Auth |
|
17 | { |
|
18 | /** @var TwitchRequest */ |
|
19 | protected $request; |
|
20 | ||
21 | const URI_AUTH = 'oauth2/authorize'; |
|
22 | const URI_AUTH_TOKEN = 'oauth2/token'; |
|
23 | ||
24 | public function __construct(TwitchRequest $request) |
|
25 | { |
|
26 | $this->request = $request; |
|
27 | } |
|
28 | ||
29 | /** |
|
30 | * Get login URL for authentication |
|
31 | * @param string $queryString |
|
32 | * @return string |
|
33 | * @throws TwitchSDKException |
|
34 | */ |
|
35 | public function getLoginURL($queryString) |
|
36 | { |
|
37 | return $this->request->request(self::URI_AUTH . $queryString); |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Get authentication access token |
|
42 | * @param string $queryString |
|
43 | * @return \stdClass |
|
44 | * @throws TwitchSDKException |
|
45 | */ |
|
46 | public function getAccessToken($queryString) |
|
47 | { |
|
48 | return $this->request->request(self::URI_AUTH_TOKEN, 'POST', $queryString); |
|
49 | } |
|
50 | } |
|
51 |
@@ 15-55 (lines=41) @@ | ||
12 | * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
|
13 | * @homepage https://github.com/jofner/Twitch-SDK |
|
14 | */ |
|
15 | class Team |
|
16 | { |
|
17 | /** @var TwitchRequest */ |
|
18 | protected $request; |
|
19 | ||
20 | const URI_TEAM = 'teams/'; |
|
21 | const URI_TEAMS = 'teams'; |
|
22 | ||
23 | /** |
|
24 | * Team constructor |
|
25 | * @param TwitchRequest $request |
|
26 | */ |
|
27 | public function __construct(TwitchRequest $request) |
|
28 | { |
|
29 | $this->request = $request; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * Get the specified team |
|
34 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md#get-teamsteam |
|
35 | * @param string $team |
|
36 | * @return \stdClass |
|
37 | * @throws TwitchSDKException |
|
38 | */ |
|
39 | public function getTeam($team) |
|
40 | { |
|
41 | return $this->request->request(self::URI_TEAM . $team); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Returns a list of active teams |
|
46 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md#get-teams |
|
47 | * @param $queryString |
|
48 | * @return \stdClass |
|
49 | * @throws TwitchSDKException |
|
50 | */ |
|
51 | public function getTeams($queryString) |
|
52 | { |
|
53 | return $this->request->request(self::URI_TEAMS . $queryString); |
|
54 | } |
|
55 | } |
|
56 |