-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace spec\NewTwitchApi\Resources; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use NewTwitchApi\RequestGenerator; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class ChatApiSpec extends ObjectBehavior | ||
{ | ||
function let(Client $guzzleClient, RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$this->beConstructedWith($guzzleClient, $requestGenerator); | ||
$guzzleClient->send($request)->willReturn($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); | ||
$this->getChannelChatBadges('TEST_TOKEN', '123')->shouldBe($response); | ||
} | ||
|
||
function it_should_get_global_chat_badges(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('GET', 'chat/badges/global', 'TEST_TOKEN', [], [])->willReturn($request); | ||
$this->getGlobalChatBadges('TEST_TOKEN')->shouldBe($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NewTwitchApi\Resources; | ||
|
||
use GuzzleHttp\Exception\GuzzleException; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class ChatApi extends AbstractResource | ||
{ | ||
/** | ||
* @throws GuzzleException | ||
* @link https://dev.twitch.tv/docs/api/reference#get-channel-chat-badges | ||
*/ | ||
public function getChannelChatBadges(string $bearer, string $broadcasterId): ResponseInterface | ||
{ | ||
$queryParamsMap = []; | ||
$queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId]; | ||
|
||
return $this->getApi('chat/badges', $bearer, $queryParamsMap); | ||
} | ||
|
||
/** | ||
* @throws GuzzleException | ||
* @link https://dev.twitch.tv/docs/api/reference#get-global-chat-badges | ||
*/ | ||
public function getGlobalChatBadges(string $bearer): ResponseInterface | ||
{ | ||
return $this->getApi('chat/badges/global', $bearer); | ||
} | ||
} |