From df3ad8b4262c35be98b30a532e3386513a159d34 Mon Sep 17 00:00:00 2001 From: ToshY <31921460+ToshY@users.noreply.github.com> Date: Wed, 3 Apr 2024 22:29:06 +0200 Subject: [PATCH] Added includeThumbnails query parameter to Stream API get and list endpoints --- docs/stream-api.md | 4 ++++ .../API/Stream/ManageCollections/GetCollection.php | 12 +++++++++++- .../API/Stream/ManageCollections/ListCollections.php | 1 + src/StreamAPI.php | 7 +++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/stream-api.md b/docs/stream-api.md index 94374e1..53d9ce4 100644 --- a/docs/stream-api.md +++ b/docs/stream-api.md @@ -34,6 +34,9 @@ $streamApi = new StreamAPI( $streamApi->getCollection( libraryId: 1, collectionId: '97f20caa-649b-4302-9f6e-1d286e0da144', + query: [ + 'includeThumbnails' => true, + ], ); ``` @@ -68,6 +71,7 @@ $streamApi->listCollections( 'perPage' => 100, 'search' => 'bunny', 'orderBy' => 'date', + 'includeThumbnails' => true, ], ); ``` diff --git a/src/Model/API/Stream/ManageCollections/GetCollection.php b/src/Model/API/Stream/ManageCollections/GetCollection.php index f991fd8..91930a3 100644 --- a/src/Model/API/Stream/ManageCollections/GetCollection.php +++ b/src/Model/API/Stream/ManageCollections/GetCollection.php @@ -6,9 +6,12 @@ use ToshY\BunnyNet\Enum\Header; use ToshY\BunnyNet\Enum\Method; +use ToshY\BunnyNet\Enum\Type; +use ToshY\BunnyNet\Model\AbstractParameter; use ToshY\BunnyNet\Model\EndpointInterface; +use ToshY\BunnyNet\Model\EndpointQueryInterface; -class GetCollection implements EndpointInterface +class GetCollection implements EndpointInterface, EndpointQueryInterface { public function getMethod(): Method { @@ -26,4 +29,11 @@ public function getHeaders(): array Header::ACCEPT_JSON, ]; } + + public function getQuery(): array + { + return [ + new AbstractParameter(name: 'includeThumbnails', type: Type::BOOLEAN_TYPE), + ]; + } } diff --git a/src/Model/API/Stream/ManageCollections/ListCollections.php b/src/Model/API/Stream/ManageCollections/ListCollections.php index 8f7f995..7480cd2 100644 --- a/src/Model/API/Stream/ManageCollections/ListCollections.php +++ b/src/Model/API/Stream/ManageCollections/ListCollections.php @@ -37,6 +37,7 @@ public function getQuery(): array new AbstractParameter(name: 'itemsPerPage', type: Type::INT_TYPE), new AbstractParameter(name: 'search', type: Type::STRING_TYPE), new AbstractParameter(name: 'orderBy', type: Type::STRING_TYPE), + new AbstractParameter(name: 'includeThumbnails', type: Type::BOOLEAN_TYPE), ]; } } diff --git a/src/StreamAPI.php b/src/StreamAPI.php index 7c9ded8..b8eaae3 100644 --- a/src/StreamAPI.php +++ b/src/StreamAPI.php @@ -49,16 +49,23 @@ public function __construct( * @throws ClientExceptionInterface * @throws Exception\BunnyClientResponseException * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException * @param string $collectionId + * @param array $query * @return BunnyClientResponseInterface * @param int $libraryId */ public function getCollection( int $libraryId, string $collectionId, + array $query = [], ): BunnyClientResponseInterface { $endpoint = new GetCollection(); + ParameterValidator::validate($query, $endpoint->getQuery()); + return $this->client->request( endpoint: $endpoint, parameters: [$libraryId, $collectionId],