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 3a94b54
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
12 changes: 12 additions & 0 deletions docs/stream-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ $streamApi = new StreamAPI(
$streamApi->getCollection(
libraryId: 1,
collectionId: '97f20caa-649b-4302-9f6e-1d286e0da144',
query: [
'includeThumbnails' => true,
],
);
```

!!! note

- If the query parameter `includeThumbnails` is set to `true`, the response item(s) will include a non-empty array key `previewImageUrls` containing the URLs for the corresponding image thumbnails.

#### [Update Collection](https://docs.bunny.net/reference/collection_updatecollection)

```php
Expand Down Expand Up @@ -68,10 +75,15 @@ $streamApi->listCollections(
'perPage' => 100,
'search' => 'bunny',
'orderBy' => 'date',
'includeThumbnails' => true,
],
);
```

!!! note

- If the query parameter `includeThumbnails` is set to `true`, the response item(s) will include a non-empty array key `previewImageUrls` containing the URLs for the corresponding image thumbnails.

#### [Create Collection](https://docs.bunny.net/reference/collection_createcollection)

```php
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),
];
}
}
8 changes: 8 additions & 0 deletions src/StreamAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,27 @@ 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],
query: $query,
);
}

Expand Down

0 comments on commit 3a94b54

Please sign in to comment.