Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added includeThumbnails query parameter to Stream API get and list endpoints #112

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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