Skip to content

Commit 0ccd0b3

Browse files
authored
Merge pull request #151 from alexschastny/add-entitlements-filter
2 parents 54c9ae2 + 967aed0 commit 0ccd0b3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

spec/TwitchApi/Resources/EntitlementsApiSpec.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ function it_should_get_drop_entitlements_by_game_id_with_opts(RequestGenerator $
7070
$this->getDropsEntitlements('TEST_TOKEN', null, null, '123', 'abc', 100)->shouldBe($response);
7171
}
7272

73+
function it_should_get_drop_entitlements_by_status(RequestGenerator $requestGenerator, Request $request, Response $response)
74+
{
75+
$requestGenerator->generate('GET', 'entitlements/drops', 'TEST_TOKEN', [['key' => 'fulfillment_status', 'value' => 'CLAIMED']], [])->willReturn($request);
76+
$this->getDropsEntitlements('TEST_TOKEN', null, null, null, null, null, 'CLAIMED')->shouldBe($response);
77+
}
78+
7379
function it_should_redeem_code(RequestGenerator $requestGenerator, Request $request, Response $response)
7480
{
7581
$requestGenerator->generate('POST', 'entitlements/code', 'TEST_TOKEN', [['key' => 'user_id', 'value' => '123'], ['key' => 'code', 'value' => 'abc']], [])->willReturn($request);

src/Resources/EntitlementsApi.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getCodeStatus(string $bearer, int $userId, array $codes = []): R
4343
* @throws GuzzleException
4444
* @link https://dev.twitch.tv/docs/api/reference#get-drops-entitlements
4545
*/
46-
public function getDropsEntitlements(string $bearer, string $id = null, string $userId = null, string $gameId = null, string $after = null, int $first = null): ResponseInterface
46+
public function getDropsEntitlements(string $bearer, string $id = null, string $userId = null, string $gameId = null, string $after = null, int $first = null, string $fulfillmentStatus = null): ResponseInterface
4747
{
4848
$queryParamsMap = [];
4949

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

70+
if ($fulfillmentStatus) {
71+
$queryParamsMap[] = ['key' => 'fulfillment_status', 'value' => $fulfillmentStatus];
72+
}
73+
7074
return $this->getApi('entitlements/drops', $bearer, $queryParamsMap);
7175
}
7276

0 commit comments

Comments
 (0)