@@ 15-80 (lines=66) @@ | ||
12 | * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
|
13 | * @homepage https://github.com/jofner/Twitch-SDK |
|
14 | */ |
|
15 | class Chat |
|
16 | { |
|
17 | /** @var TwitchRequest */ |
|
18 | protected $request; |
|
19 | ||
20 | const URI_CHAT = 'chat/'; |
|
21 | const URI_CHAT_EMOTICONS = 'chat/emoticons'; |
|
22 | const URI_CHAT_EMOTICONS_IMAGES = 'chat/emoticon_images'; |
|
23 | const URI_CHAT_BADGES = 'chat/%s/badges'; |
|
24 | ||
25 | /** |
|
26 | * Chat constructor |
|
27 | * @param TwitchRequest $request |
|
28 | */ |
|
29 | public function __construct(TwitchRequest $request) |
|
30 | { |
|
31 | $this->request = $request; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * Returns a links object to all other chat endpoints |
|
36 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatchannel |
|
37 | * @param string $channel |
|
38 | * @return \stdClass |
|
39 | * @throws TwitchSDKException |
|
40 | */ |
|
41 | public function getChat($channel) |
|
42 | { |
|
43 | return $this->request->request(self::URI_CHAT . $channel); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Get a chat's emoticons |
|
48 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatemoticons |
|
49 | * @return \stdClass |
|
50 | * @throws TwitchSDKException |
|
51 | */ |
|
52 | public function getEmoticons() |
|
53 | { |
|
54 | return $this->request->request(self::URI_CHAT_EMOTICONS); |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * Returns a list of emoticons |
|
59 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatemoticon_images |
|
60 | * @param string $queryString |
|
61 | * @return \stdClass |
|
62 | * @throws TwitchSDKException |
|
63 | */ |
|
64 | public function getEmoticonImages($queryString) |
|
65 | { |
|
66 | return $this->request->request(self::URI_CHAT_EMOTICONS_IMAGES . $queryString); |
|
67 | } |
|
68 | ||
69 | /** |
|
70 | * Returns a list of chat badges that can be used in the :channel's chat |
|
71 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatchannelbadges |
|
72 | * @param string $channel |
|
73 | * @return \stdClass |
|
74 | * @throws TwitchSDKException |
|
75 | */ |
|
76 | public function getBadges($channel) |
|
77 | { |
|
78 | return $this->request->request(sprintf(self::URI_CHAT_BADGES, $channel)); |
|
79 | } |
|
80 | } |
|
81 |
@@ 15-81 (lines=67) @@ | ||
12 | * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
|
13 | * @homepage https://github.com/jofner/Twitch-SDK |
|
14 | */ |
|
15 | class Stream |
|
16 | { |
|
17 | /** @var TwitchRequest */ |
|
18 | protected $request; |
|
19 | ||
20 | const URI_STREAM = 'streams/'; |
|
21 | const URI_STREAMS = 'streams'; |
|
22 | const URI_STREAMS_FEATURED = 'streams/featured'; |
|
23 | const URI_STREAM_SUMMARY = 'streams/summary'; |
|
24 | ||
25 | /** |
|
26 | * Stream constructor |
|
27 | * @param TwitchRequest $request |
|
28 | */ |
|
29 | public function __construct(TwitchRequest $request) |
|
30 | { |
|
31 | $this->request = $request; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * Get the specified channel's stream |
|
36 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamschannel |
|
37 | * @param string $channel |
|
38 | * @return \stdClass |
|
39 | * @throws TwitchSDKException |
|
40 | */ |
|
41 | public function getStream($channel) |
|
42 | { |
|
43 | return $this->request->request(self::URI_STREAM . $channel); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Returns a list of streams |
|
48 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streams |
|
49 | * @param string $queryString |
|
50 | * @return \stdClass |
|
51 | * @throws TwitchSDKException |
|
52 | */ |
|
53 | public function getStreams($queryString) |
|
54 | { |
|
55 | return $this->request->request(self::URI_STREAMS . $queryString); |
|
56 | } |
|
57 | ||
58 | /** |
|
59 | * Returns a list of featured (promoted) stream |
|
60 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamsfeatured |
|
61 | * @param string $queryString |
|
62 | * @return \stdClass |
|
63 | * @throws TwitchSDKException |
|
64 | */ |
|
65 | public function getFeatured($queryString) |
|
66 | { |
|
67 | return $this->request->request(self::URI_STREAMS_FEATURED . $queryString); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Returns a summary of current streams |
|
72 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamssummary |
|
73 | * @param string $queryString |
|
74 | * @return \stdClass |
|
75 | * @throws TwitchSDKException |
|
76 | */ |
|
77 | public function getSummary($queryString) |
|
78 | { |
|
79 | return $this->request->request(self::URI_STREAM_SUMMARY . $queryString); |
|
80 | } |
|
81 | } |
|
82 |
@@ 15-80 (lines=66) @@ | ||
12 | * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT |
|
13 | * @homepage https://github.com/jofner/Twitch-SDK |
|
14 | */ |
|
15 | class User |
|
16 | { |
|
17 | /** @var TwitchRequest */ |
|
18 | protected $request; |
|
19 | ||
20 | const URI_USER = 'users/'; |
|
21 | const URI_USER_AUTH = 'user'; |
|
22 | const URI_STREAMS_FOLLOWED_AUTH = 'streams/followed'; |
|
23 | const URI_VIDEOS_FOLLOWED_AUTH = 'videos/followed'; |
|
24 | ||
25 | public function __construct(TwitchRequest $request) |
|
26 | { |
|
27 | $this->request = $request; |
|
28 | } |
|
29 | ||
30 | /** |
|
31 | * Get the specified user |
|
32 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-usersuser |
|
33 | * @param string $username |
|
34 | * @return \stdClass |
|
35 | * @throws TwitchSDKException |
|
36 | */ |
|
37 | public function getUser($username) |
|
38 | { |
|
39 | return $this->request->request(self::URI_USER . $username); |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * Get the authenticated user |
|
44 | * - requires scope 'user_read' |
|
45 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-user |
|
46 | * @param string $queryString |
|
47 | * @return \stdClass |
|
48 | * @throws TwitchSDKException |
|
49 | */ |
|
50 | public function getUserAuth($queryString) |
|
51 | { |
|
52 | return $this->request->request(self::URI_USER_AUTH . $queryString); |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * List the live streams that the authenticated user is following |
|
57 | * - requires scope 'user_read' |
|
58 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-streamsfollowed |
|
59 | * @param string $queryString |
|
60 | * @return \stdClass |
|
61 | * @throws TwitchSDKException |
|
62 | */ |
|
63 | public function getFollowedStreams($queryString) |
|
64 | { |
|
65 | return $this->request->request(self::URI_STREAMS_FOLLOWED_AUTH . $queryString); |
|
66 | } |
|
67 | ||
68 | /** |
|
69 | * List of videos that the authenticated user is following |
|
70 | * - requires scope 'user_read' |
|
71 | * @see https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md#get-videosfollowed |
|
72 | * @param string $queryString |
|
73 | * @return \stdClass |
|
74 | * @throws TwitchSDKException |
|
75 | */ |
|
76 | public function getFollowedVideos($queryString) |
|
77 | { |
|
78 | return $this->request->request(self::URI_VIDEOS_FOLLOWED_AUTH . $queryString); |
|
79 | } |
|
80 | } |
|
81 |