@@ 15-68 (lines=54) @@ | ||
12 | * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
|
13 | * @homepage https://github.com/jofner/Twitch-SDK |
|
14 | */ |
|
15 | class Search |
|
16 | { |
|
17 | /** @var TwitchRequest */ |
|
18 | protected $request; |
|
19 | ||
20 | const URI_SEARCH_CHANNELS = 'search/channels'; |
|
21 | const URI_SEARCH_STREAMS = 'search/streams'; |
|
22 | const URI_SEARCH_GAMES = 'search/games'; |
|
23 | ||
24 | /** |
|
25 | * Search constructor |
|
26 | * @param TwitchRequest $request |
|
27 | */ |
|
28 | public function __construct(TwitchRequest $request) |
|
29 | { |
|
30 | $this->request = $request; |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * Search for channel |
|
35 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md#get-searchchannels |
|
36 | * @param string $queryString |
|
37 | * @return \stdClass |
|
38 | * @throws TwitchSDKException |
|
39 | */ |
|
40 | public function channels($queryString) |
|
41 | { |
|
42 | return $this->request->request(self::URI_SEARCH_CHANNELS . $queryString); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * Search streams |
|
47 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md#get-searchstreams |
|
48 | * @param string $queryString |
|
49 | * @return \stdClass |
|
50 | * @throws TwitchSDKException |
|
51 | */ |
|
52 | public function streams($queryString) |
|
53 | { |
|
54 | return $this->request->request(self::URI_SEARCH_STREAMS . $queryString); |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * Search games |
|
59 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md#get-searchgames |
|
60 | * @param string $queryString |
|
61 | * @return \stdClass |
|
62 | * @throws TwitchSDKException |
|
63 | */ |
|
64 | public function games($queryString) |
|
65 | { |
|
66 | return $this->request->request(self::URI_SEARCH_STREAMS . $queryString); |
|
67 | } |
|
68 | } |
|
69 |
@@ 15-69 (lines=55) @@ | ||
12 | * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
|
13 | * @homepage https://github.com/jofner/Twitch-SDK |
|
14 | */ |
|
15 | class Video |
|
16 | { |
|
17 | /** @var TwitchRequest */ |
|
18 | protected $request; |
|
19 | ||
20 | const URI_VIDEO = 'videos/'; |
|
21 | const URI_VIDEO_TOP = 'videos/top'; |
|
22 | const URI_VIDEO_CHANNEL = 'channels/%s/videos'; |
|
23 | ||
24 | /** |
|
25 | * Video constructor |
|
26 | * @param TwitchRequest $request |
|
27 | */ |
|
28 | public function __construct(TwitchRequest $request) |
|
29 | { |
|
30 | $this->request = $request; |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * Returns a video object |
|
35 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-videosid |
|
36 | * @param string $id |
|
37 | * @return \stdClass |
|
38 | * @throws TwitchSDKException |
|
39 | */ |
|
40 | public function getVideo($id) |
|
41 | { |
|
42 | return $this->request->request(self::URI_VIDEO . $id); |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * Returns a list of videos created in a given time period sorted by number of views, most popular first |
|
47 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-videostop |
|
48 | * @param string $queryString |
|
49 | * @return \stdClass |
|
50 | * @throws TwitchSDKException |
|
51 | */ |
|
52 | public function getTop($queryString) |
|
53 | { |
|
54 | return $this->request->request(self::URI_VIDEO_TOP . $queryString); |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * Returns a list of videos ordered by time of creation, starting with the most recent from :channel |
|
59 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/videos.md#get-channelschannelvideos |
|
60 | * @param string $channel |
|
61 | * @param string $queryString |
|
62 | * @return \stdClass |
|
63 | * @throws TwitchSDKException |
|
64 | */ |
|
65 | public function getChannelVideos($channel, $queryString) |
|
66 | { |
|
67 | return $this->request->request(sprintf(self::URI_VIDEO_CHANNEL, $channel) . $queryString); |
|
68 | } |
|
69 | } |
|
70 |