From 967aed0e538625821a8374c23d8aa322c565a541 Mon Sep 17 00:00:00 2001 From: alexschastny Date: Wed, 31 May 2023 22:04:06 +0200 Subject: [PATCH] add FulfillmentStatus filter to getDropsEntitlements method --- spec/TwitchApi/Resources/EntitlementsApiSpec.php | 6 ++++++ src/Resources/EntitlementsApi.php | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/TwitchApi/Resources/EntitlementsApiSpec.php b/spec/TwitchApi/Resources/EntitlementsApiSpec.php index 71d7ca8..b3b674d 100644 --- a/spec/TwitchApi/Resources/EntitlementsApiSpec.php +++ b/spec/TwitchApi/Resources/EntitlementsApiSpec.php @@ -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); diff --git a/src/Resources/EntitlementsApi.php b/src/Resources/EntitlementsApi.php index f6b5a89..3e27ae9 100644 --- a/src/Resources/EntitlementsApi.php +++ b/src/Resources/EntitlementsApi.php @@ -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 = []; @@ -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); }