Skip to content

Commit 21a3a20

Browse files
committed
Add getFollowedStreams
1 parent f7ad279 commit 21a3a20

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

spec/NewTwitchApi/Resources/StreamsApiSpec.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,16 @@ function it_should_get_streams_by_everything(Client $guzzleClient, Response $res
9292
$guzzleClient->send(new Request('GET', 'streams?user_id=12&user_id=34&user_login=twitchuser&user_login=anotheruser&game_id=56&game_id=78&language=en&language=de&first=100&before=200&after=300', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response);
9393
$this->getStreams('TEST_TOKEN', ['12', '34'], ['twitchuser', 'anotheruser'], ['56', '78'], ['en', 'de'], 100, 200, 300)->shouldBeAnInstanceOf(ResponseInterface::class);
9494
}
95+
96+
function it_should_get_followed_streams(Client $guzzleClient, Response $response)
97+
{
98+
$guzzleClient->send(new Request('GET', 'streams/followed?user_id=123', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response);
99+
$this->getFollowedStreams('TEST_TOKEN', '123')->shouldBeAnInstanceOf(ResponseInterface::class);
100+
}
101+
102+
function it_should_get_followed_streams_with_everything(Client $guzzleClient, Response $response)
103+
{
104+
$guzzleClient->send(new Request('GET', 'streams/followed?user_id=123&first=100&after=abc', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response);
105+
$this->getFollowedStreams('TEST_TOKEN', '123', 100, 'abc')->shouldBeAnInstanceOf(ResponseInterface::class);
106+
}
95107
}

src/NewTwitchApi/Resources/StreamsApi.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,25 @@ public function getStreamTags(string $bearer, string $broadcasterId): ResponseIn
179179

180180
return $this->getApi('streams/tags', $bearer, $queryParamsMap);
181181
}
182+
183+
/**
184+
* @throws GuzzleException
185+
* @link https://dev.twitch.tv/docs/api/reference/#get-followed-streams
186+
*/
187+
public function getFollowedStreams(string $bearer, string $userId, int $first = null, string $after = null): ResponseInterface
188+
{
189+
$queryParamsMap = [];
190+
191+
$queryParamsMap[] = ['key' => 'user_id', 'value' => $userId];
192+
193+
if ($first) {
194+
$queryParamsMap[] = ['key' => 'first', 'value' => $first];
195+
}
196+
197+
if ($after) {
198+
$queryParamsMap[] = ['key' => 'after', 'value' => $after];
199+
}
200+
201+
return $this->getApi('streams/followed', $bearer, $queryParamsMap);
202+
}
182203
}

0 commit comments

Comments
 (0)