Skip to content

Commit

Permalink
Merge pull request #129 from nicklaw5/v5-0-3
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandin authored Jun 9, 2021
2 parents 1610ead + 5c7886d commit 6a41391
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
30 changes: 30 additions & 0 deletions spec/NewTwitchApi/Resources/ChatApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@ function let(HelixGuzzleClient $guzzleClient, RequestGenerator $requestGenerator
$guzzleClient->send($request)->willReturn($response);
}

function it_should_get_channel_emotes(RequestGenerator $requestGenerator, Request $request, Response $response)
{
$requestGenerator->generate('GET', 'chat/emotes', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123']], [])->willReturn($request);
$this->getChannelEmotes('TEST_TOKEN', '123')->shouldBe($response);
}

function it_should_get_global_emotes(RequestGenerator $requestGenerator, Request $request, Response $response)
{
$requestGenerator->generate('GET', 'chat/emotes/global', 'TEST_TOKEN', [], [])->willReturn($request);
$this->getGlobalEmotes('TEST_TOKEN')->shouldBe($response);
}

function it_should_get_one_emote_set(RequestGenerator $requestGenerator, Request $request, Response $response)
{
$requestGenerator->generate('GET', 'chat/emotes/set', 'TEST_TOKEN', [['key' => 'emote_set_id', 'value' => '123']], [])->willReturn($request);
$this->getEmoteSets('TEST_TOKEN', ['123'])->shouldBe($response);
}

function it_should_get_one_emote_set_with_helper_function(RequestGenerator $requestGenerator, Request $request, Response $response)
{
$requestGenerator->generate('GET', 'chat/emotes/set', 'TEST_TOKEN', [['key' => 'emote_set_id', 'value' => '123']], [])->willReturn($request);
$this->getEmoteSet('TEST_TOKEN', '123')->shouldBe($response);
}

function it_should_get_multiple_emote_sets(RequestGenerator $requestGenerator, Request $request, Response $response)
{
$requestGenerator->generate('GET', 'chat/emotes/set', 'TEST_TOKEN', [['key' => 'emote_set_id', 'value' => '123'], ['key' => 'emote_set_id', 'value' => '456']], [])->willReturn($request);
$this->getEmoteSets('TEST_TOKEN', ['123', '456'])->shouldBe($response);
}

function it_should_get_channel_chat_badges(RequestGenerator $requestGenerator, Request $request, Response $response)
{
$requestGenerator->generate('GET', 'chat/badges', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123']], [])->willReturn($request);
Expand Down
44 changes: 44 additions & 0 deletions src/NewTwitchApi/Resources/ChatApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,50 @@

class ChatApi extends AbstractResource
{
/**
* @throws GuzzleException
* @link https://dev.twitch.tv/docs/api/reference#get-channel-emotes
*/
public function getChannelEmotes(string $bearer, string $broadcasterId): ResponseInterface
{
$queryParamsMap = [];
$queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId];

return $this->getApi('chat/emotes', $bearer, $queryParamsMap);
}

/**
* @throws GuzzleException
* @link https://dev.twitch.tv/docs/api/reference#get-global-emotes
*/
public function getGlobalEmotes(string $bearer): ResponseInterface
{
return $this->getApi('chat/emotes/global', $bearer);
}

/**
* @throws GuzzleException
* @link https://dev.twitch.tv/docs/api/reference#get-emote-sets
*/
public function getEmoteSets(string $bearer, array $emoteSetIds = []): ResponseInterface
{
$queryParamsMap = [];

foreach ($emoteSetIds as $emoteSetId) {
$queryParamsMap[] = ['key' => 'emote_set_id', 'value' => $emoteSetId];
}

return $this->getApi('chat/emotes/set', $bearer, $queryParamsMap);
}

public function getEmoteSet(string $bearer, string $emoteSetId): ResponseInterface
{
$queryParamsMap = [];
$queryParamsMap[] = ['key' => 'emote_set_id', 'value' => $emoteSetId];

return $this->getApi('chat/emotes/set', $bearer, $queryParamsMap);
}

/**
* @throws GuzzleException
* @link https://dev.twitch.tv/docs/api/reference#get-channel-chat-badges
Expand Down

0 comments on commit 6a41391

Please sign in to comment.