Skip to content

Commit b2837a7

Browse files
committed
Add StreamsApi->createStreamMarker
1 parent a850505 commit b2837a7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

spec/NewTwitchApi/Resources/StreamsApiSpec.php

+12
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,16 @@ function it_should_get_followed_streams_with_opts(RequestGenerator $requestGener
142142
$requestGenerator->generate('GET', 'streams/followed', 'TEST_TOKEN', [['key' => 'user_id', 'value' => '123'], ['key' => 'first', 'value' => 100], ['key' => 'after', 'value' => 'abc']], [])->willReturn($request);
143143
$this->getFollowedStreams('TEST_TOKEN', '123', 100, 'abc')->shouldBe($response);
144144
}
145+
146+
function it_should_create_stream_marker(RequestGenerator $requestGenerator, Request $request, Response $response)
147+
{
148+
$requestGenerator->generate('POST', 'streams/markers', 'TEST_TOKEN', [], [['key' => 'user_id', 'value' => '123']])->willReturn($request);
149+
$this->createStreamMarker('TEST_TOKEN', '123')->shouldBe($response);
150+
}
151+
152+
function it_should_create_stream_marker_with_description(RequestGenerator $requestGenerator, Request $request, Response $response)
153+
{
154+
$requestGenerator->generate('POST', 'streams/markers', 'TEST_TOKEN', [], [['key' => 'user_id', 'value' => '123'], ['key' => 'description', 'value' => 'This is a marker']])->willReturn($request);
155+
$this->createStreamMarker('TEST_TOKEN', '123', 'This is a marker')->shouldBe($response);
156+
}
145157
}

src/NewTwitchApi/Resources/StreamsApi.php

+16
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,20 @@ public function getFollowedStreams(string $bearer, string $userId, int $first =
137137

138138
return $this->getApi('streams/followed', $bearer, $queryParamsMap);
139139
}
140+
141+
/**
142+
* @throws GuzzleException
143+
* @link https://dev.twitch.tv/docs/api/reference#create-stream-marker
144+
*/
145+
public function createStreamMarker(string $bearer, string $userId, string $description = null): ResponseInterface
146+
{
147+
$bodyParamsMap = [];
148+
149+
$bodyParamsMap[] = ['key' => 'user_id', 'value' => $userId];
150+
if ($description) {
151+
$bodyParamsMap[] = ['key' => 'description', 'value' => $description];
152+
}
153+
154+
return $this->postApi('streams/markers', $bearer, [], $bodyParamsMap);
155+
}
140156
}

0 commit comments

Comments
 (0)