Skip to content

Commit 6a41391

Browse files
authored
Merge pull request #129 from nicklaw5/v5-0-3
2 parents 1610ead + 5c7886d commit 6a41391

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

spec/NewTwitchApi/Resources/ChatApiSpec.php

+30
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ function let(HelixGuzzleClient $guzzleClient, RequestGenerator $requestGenerator
1616
$guzzleClient->send($request)->willReturn($response);
1717
}
1818

19+
function it_should_get_channel_emotes(RequestGenerator $requestGenerator, Request $request, Response $response)
20+
{
21+
$requestGenerator->generate('GET', 'chat/emotes', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123']], [])->willReturn($request);
22+
$this->getChannelEmotes('TEST_TOKEN', '123')->shouldBe($response);
23+
}
24+
25+
function it_should_get_global_emotes(RequestGenerator $requestGenerator, Request $request, Response $response)
26+
{
27+
$requestGenerator->generate('GET', 'chat/emotes/global', 'TEST_TOKEN', [], [])->willReturn($request);
28+
$this->getGlobalEmotes('TEST_TOKEN')->shouldBe($response);
29+
}
30+
31+
function it_should_get_one_emote_set(RequestGenerator $requestGenerator, Request $request, Response $response)
32+
{
33+
$requestGenerator->generate('GET', 'chat/emotes/set', 'TEST_TOKEN', [['key' => 'emote_set_id', 'value' => '123']], [])->willReturn($request);
34+
$this->getEmoteSets('TEST_TOKEN', ['123'])->shouldBe($response);
35+
}
36+
37+
function it_should_get_one_emote_set_with_helper_function(RequestGenerator $requestGenerator, Request $request, Response $response)
38+
{
39+
$requestGenerator->generate('GET', 'chat/emotes/set', 'TEST_TOKEN', [['key' => 'emote_set_id', 'value' => '123']], [])->willReturn($request);
40+
$this->getEmoteSet('TEST_TOKEN', '123')->shouldBe($response);
41+
}
42+
43+
function it_should_get_multiple_emote_sets(RequestGenerator $requestGenerator, Request $request, Response $response)
44+
{
45+
$requestGenerator->generate('GET', 'chat/emotes/set', 'TEST_TOKEN', [['key' => 'emote_set_id', 'value' => '123'], ['key' => 'emote_set_id', 'value' => '456']], [])->willReturn($request);
46+
$this->getEmoteSets('TEST_TOKEN', ['123', '456'])->shouldBe($response);
47+
}
48+
1949
function it_should_get_channel_chat_badges(RequestGenerator $requestGenerator, Request $request, Response $response)
2050
{
2151
$requestGenerator->generate('GET', 'chat/badges', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123']], [])->willReturn($request);

src/NewTwitchApi/Resources/ChatApi.php

+44
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,50 @@
99

1010
class ChatApi extends AbstractResource
1111
{
12+
/**
13+
* @throws GuzzleException
14+
* @link https://dev.twitch.tv/docs/api/reference#get-channel-emotes
15+
*/
16+
public function getChannelEmotes(string $bearer, string $broadcasterId): ResponseInterface
17+
{
18+
$queryParamsMap = [];
19+
$queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId];
20+
21+
return $this->getApi('chat/emotes', $bearer, $queryParamsMap);
22+
}
23+
24+
/**
25+
* @throws GuzzleException
26+
* @link https://dev.twitch.tv/docs/api/reference#get-global-emotes
27+
*/
28+
public function getGlobalEmotes(string $bearer): ResponseInterface
29+
{
30+
return $this->getApi('chat/emotes/global', $bearer);
31+
}
32+
33+
/**
34+
* @throws GuzzleException
35+
* @link https://dev.twitch.tv/docs/api/reference#get-emote-sets
36+
*/
37+
public function getEmoteSets(string $bearer, array $emoteSetIds = []): ResponseInterface
38+
{
39+
$queryParamsMap = [];
40+
41+
foreach ($emoteSetIds as $emoteSetId) {
42+
$queryParamsMap[] = ['key' => 'emote_set_id', 'value' => $emoteSetId];
43+
}
44+
45+
return $this->getApi('chat/emotes/set', $bearer, $queryParamsMap);
46+
}
47+
48+
public function getEmoteSet(string $bearer, string $emoteSetId): ResponseInterface
49+
{
50+
$queryParamsMap = [];
51+
$queryParamsMap[] = ['key' => 'emote_set_id', 'value' => $emoteSetId];
52+
53+
return $this->getApi('chat/emotes/set', $bearer, $queryParamsMap);
54+
}
55+
1256
/**
1357
* @throws GuzzleException
1458
* @link https://dev.twitch.tv/docs/api/reference#get-channel-chat-badges

0 commit comments

Comments
 (0)