Skip to content

Commit

Permalink
Added includeThumbnails query parameter to Stream API get and list en…
Browse files Browse the repository at this point in the history
…dpoints
  • Loading branch information
ToshY committed Apr 3, 2024
1 parent bb51c8d commit df3ad8b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/stream-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ $streamApi = new StreamAPI(
$streamApi->getCollection(
libraryId: 1,
collectionId: '97f20caa-649b-4302-9f6e-1d286e0da144',
query: [
'includeThumbnails' => true,
],
);
```

Expand Down Expand Up @@ -68,6 +71,7 @@ $streamApi->listCollections(
'perPage' => 100,
'search' => 'bunny',
'orderBy' => 'date',
'includeThumbnails' => true,
],
);
```
Expand Down
12 changes: 11 additions & 1 deletion src/Model/API/Stream/ManageCollections/GetCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -26,4 +29,11 @@ public function getHeaders(): array
Header::ACCEPT_JSON,
];
}

public function getQuery(): array
{
return [
new AbstractParameter(name: 'includeThumbnails', type: Type::BOOLEAN_TYPE),
];
}
}
1 change: 1 addition & 0 deletions src/Model/API/Stream/ManageCollections/ListCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
}
}
7 changes: 7 additions & 0 deletions src/StreamAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string,mixed> $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],
Expand Down

0 comments on commit df3ad8b

Please sign in to comment.