-
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.
Merge pull request #109 from brandinarsenault/mar-2021-update
Add Endpoints for March 2021
- Loading branch information
Showing
8 changed files
with
215 additions
and
1 deletion.
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
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,29 @@ | ||
<?php | ||
|
||
namespace spec\NewTwitchApi\Resources; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use PhpSpec\ObjectBehavior; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class ChannelsApiSpec extends ObjectBehavior | ||
{ | ||
function let(Client $guzzleClient) | ||
{ | ||
$this->beConstructedWith($guzzleClient); | ||
} | ||
|
||
function it_should_get_channel_info(Client $guzzleClient, Response $response) | ||
{ | ||
$guzzleClient->send(new Request('GET', 'channels?broadcaster_id=123', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); | ||
$this->getChannelInfo('TEST_TOKEN', '123')->shouldBeAnInstanceOf(ResponseInterface::class); | ||
} | ||
|
||
function it_should_get_channel_editors(Client $guzzleClient, Response $response) | ||
{ | ||
$guzzleClient->send(new Request('GET', 'channels/editors?broadcaster_id=123', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); | ||
$this->getChannelEditors('TEST_TOKEN', '123')->shouldBeAnInstanceOf(ResponseInterface::class); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace spec\NewTwitchApi\Resources; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use PhpSpec\ObjectBehavior; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class VideosApiSpec extends ObjectBehavior | ||
{ | ||
function let(Client $guzzleClient) | ||
{ | ||
$this->beConstructedWith($guzzleClient); | ||
} | ||
|
||
function it_should_delete_videos(Client $guzzleClient, Response $response) | ||
{ | ||
$guzzleClient->send(new Request('DELETE', 'videos?id=123', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); | ||
$this->deleteVideos('TEST_TOKEN', ['123'])->shouldBeAnInstanceOf(ResponseInterface::class); | ||
} | ||
|
||
function it_should_delete_multiple_videos(Client $guzzleClient, Response $response) | ||
{ | ||
$guzzleClient->send(new Request('DELETE', 'videos?id=123&id=321', ['Authorization' => 'Bearer TEST_TOKEN']))->willReturn($response); | ||
$this->deleteVideos('TEST_TOKEN', ['123', '321'])->shouldBeAnInstanceOf(ResponseInterface::class); | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NewTwitchApi\Resources; | ||
|
||
use GuzzleHttp\Exception\GuzzleException; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class ChannelsApi extends AbstractResource | ||
{ | ||
/** | ||
* @throws GuzzleException | ||
* @link https://dev.twitch.tv/docs/api/reference#get-channel-information | ||
*/ | ||
public function getChannelInfo(string $bearer, string $broadcasterId): ResponseInterface | ||
{ | ||
$queryParamsMap = []; | ||
|
||
$queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId]; | ||
|
||
return $this->getApi('channels', $bearer, $queryParamsMap); | ||
} | ||
|
||
/** | ||
* @throws GuzzleException | ||
* @link https://dev.twitch.tv/docs/api/reference#get-channel-editors | ||
*/ | ||
public function getChannelEditors(string $bearer, string $broadcasterId): ResponseInterface | ||
{ | ||
$queryParamsMap = []; | ||
|
||
$queryParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId]; | ||
|
||
return $this->getApi('channels/editors', $bearer, $queryParamsMap); | ||
} | ||
} |
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