Skip to content

Commit

Permalink
Merge pull request #151 from alexschastny/add-entitlements-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandin committed Jun 10, 2023
2 parents 54c9ae2 + 967aed0 commit 0ccd0b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions spec/TwitchApi/Resources/EntitlementsApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ function it_should_get_drop_entitlements_by_game_id_with_opts(RequestGenerator $
$this->getDropsEntitlements('TEST_TOKEN', null, null, '123', 'abc', 100)->shouldBe($response);
}

function it_should_get_drop_entitlements_by_status(RequestGenerator $requestGenerator, Request $request, Response $response)
{
$requestGenerator->generate('GET', 'entitlements/drops', 'TEST_TOKEN', [['key' => 'fulfillment_status', 'value' => 'CLAIMED']], [])->willReturn($request);
$this->getDropsEntitlements('TEST_TOKEN', null, null, null, null, null, 'CLAIMED')->shouldBe($response);
}

function it_should_redeem_code(RequestGenerator $requestGenerator, Request $request, Response $response)
{
$requestGenerator->generate('POST', 'entitlements/code', 'TEST_TOKEN', [['key' => 'user_id', 'value' => '123'], ['key' => 'code', 'value' => 'abc']], [])->willReturn($request);
Expand Down
6 changes: 5 additions & 1 deletion src/Resources/EntitlementsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getCodeStatus(string $bearer, int $userId, array $codes = []): R
* @throws GuzzleException
* @link https://dev.twitch.tv/docs/api/reference#get-drops-entitlements
*/
public function getDropsEntitlements(string $bearer, string $id = null, string $userId = null, string $gameId = null, string $after = null, int $first = null): ResponseInterface
public function getDropsEntitlements(string $bearer, string $id = null, string $userId = null, string $gameId = null, string $after = null, int $first = null, string $fulfillmentStatus = null): ResponseInterface
{
$queryParamsMap = [];

Expand All @@ -67,6 +67,10 @@ public function getDropsEntitlements(string $bearer, string $id = null, string $
$queryParamsMap[] = ['key' => 'first', 'value' => $first];
}

if ($fulfillmentStatus) {
$queryParamsMap[] = ['key' => 'fulfillment_status', 'value' => $fulfillmentStatus];
}

return $this->getApi('entitlements/drops', $bearer, $queryParamsMap);
}

Expand Down

0 comments on commit 0ccd0b3

Please sign in to comment.