-
Notifications
You must be signed in to change notification settings - Fork 48
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 #123 from nicklaw5/v5-release
- Loading branch information
Showing
19 changed files
with
441 additions
and
92 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
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,24 @@ | ||
<?php | ||
|
||
namespace spec\NewTwitchApi\Resources; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
use NewTwitchApi\RequestGenerator; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class AdsApiSpec extends ObjectBehavior | ||
{ | ||
function let(Client $guzzleClient, RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$this->beConstructedWith($guzzleClient, $requestGenerator); | ||
$guzzleClient->send($request)->willReturn($response); | ||
} | ||
|
||
function it_should_start_commercial(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('POST', 'channels/commercial', 'TEST_TOKEN', [], [['key' => 'broadcaster_id', 'value' => '123'], ['key' => 'length', 'value' => 30]])->willReturn($request); | ||
$this->startCommercial('TEST_TOKEN', '123', 30)->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
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 ModerationApiSpec extends ObjectBehavior | ||
{ | ||
function let(Client $guzzleClient, RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$this->beConstructedWith($guzzleClient, $requestGenerator); | ||
$guzzleClient->send($request)->willReturn($response); | ||
} | ||
|
||
function it_should_check_automod_status(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('POST', 'moderation/enforcements/status', 'TEST_TOKEN', [['key' => 'broadcaster_id', 'value' => '123']], [['key' => 'msg_id', 'value' => '456'], ['key' => 'msg_text', 'value' => 'test 123'], ['key' => 'user_id', 'value' => '789']])->willReturn($request); | ||
$this->checkAutoModStatus('TEST_TOKEN', '123', '456', 'test 123', '789')->shouldBe($response); | ||
} | ||
|
||
function it_should_release_held_message(RequestGenerator $requestGenerator, Request $request, Response $response) | ||
{ | ||
$requestGenerator->generate('POST', 'moderation/automod/message', 'TEST_TOKEN', [], [['key' => 'user_id', 'value' => '123'], ['key' => 'msg_id', 'value' => '456'], ['key' => 'action', 'value' => 'ALLOW']])->willReturn($request); | ||
$this->manageHeldAutoModMessage('TEST_TOKEN', '123', '456', 'ALLOW')->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
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
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NewTwitchApi\Resources; | ||
|
||
use GuzzleHttp\Exception\GuzzleException; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
class AdsApi extends AbstractResource | ||
{ | ||
/** | ||
* @throws GuzzleException | ||
* @link https://dev.twitch.tv/docs/api/reference#start-commercial | ||
*/ | ||
public function startCommercial(string $bearer, string $broadcasterId, int $length): ResponseInterface | ||
{ | ||
$bodyParamsMap = []; | ||
|
||
$bodyParamsMap[] = ['key' => 'broadcaster_id', 'value' => $broadcasterId]; | ||
$bodyParamsMap[] = ['key' => 'length', 'value' => $length]; | ||
|
||
return $this->postApi('channels/commercial', $bearer, [], $bodyParamsMap); | ||
} | ||
} |
Oops, something went wrong.