Skip to content

Commit 1610c8c

Browse files
authored
Merge pull request #112 from ToshY/bug/111
Added `includeThumbnails` query parameter to Stream API get and list endpoints
2 parents 7586fdd + 3a94b54 commit 1610c8c

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

Diff for: docs/stream-api.md

+12
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ $streamApi = new StreamAPI(
3434
$streamApi->getCollection(
3535
libraryId: 1,
3636
collectionId: '97f20caa-649b-4302-9f6e-1d286e0da144',
37+
query: [
38+
'includeThumbnails' => true,
39+
],
3740
);
3841
```
3942

43+
!!! note
44+
45+
- 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.
46+
4047
#### [Update Collection](https://docs.bunny.net/reference/collection_updatecollection)
4148

4249
```php
@@ -68,10 +75,15 @@ $streamApi->listCollections(
6875
'perPage' => 100,
6976
'search' => 'bunny',
7077
'orderBy' => 'date',
78+
'includeThumbnails' => true,
7179
],
7280
);
7381
```
7482

83+
!!! note
84+
85+
- 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.
86+
7587
#### [Create Collection](https://docs.bunny.net/reference/collection_createcollection)
7688

7789
```php

Diff for: src/Model/API/Stream/ManageCollections/GetCollection.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
use ToshY\BunnyNet\Enum\Header;
88
use ToshY\BunnyNet\Enum\Method;
9+
use ToshY\BunnyNet\Enum\Type;
10+
use ToshY\BunnyNet\Model\AbstractParameter;
911
use ToshY\BunnyNet\Model\EndpointInterface;
12+
use ToshY\BunnyNet\Model\EndpointQueryInterface;
1013

11-
class GetCollection implements EndpointInterface
14+
class GetCollection implements EndpointInterface, EndpointQueryInterface
1215
{
1316
public function getMethod(): Method
1417
{
@@ -26,4 +29,11 @@ public function getHeaders(): array
2629
Header::ACCEPT_JSON,
2730
];
2831
}
32+
33+
public function getQuery(): array
34+
{
35+
return [
36+
new AbstractParameter(name: 'includeThumbnails', type: Type::BOOLEAN_TYPE),
37+
];
38+
}
2939
}

Diff for: src/Model/API/Stream/ManageCollections/ListCollections.php

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function getQuery(): array
3737
new AbstractParameter(name: 'itemsPerPage', type: Type::INT_TYPE),
3838
new AbstractParameter(name: 'search', type: Type::STRING_TYPE),
3939
new AbstractParameter(name: 'orderBy', type: Type::STRING_TYPE),
40+
new AbstractParameter(name: 'includeThumbnails', type: Type::BOOLEAN_TYPE),
4041
];
4142
}
4243
}

Diff for: src/StreamAPI.php

+8
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,27 @@ public function __construct(
4949
* @throws ClientExceptionInterface
5050
* @throws Exception\BunnyClientResponseException
5151
* @throws Exception\JSONException
52+
* @throws Exception\InvalidTypeForKeyValueException
53+
* @throws Exception\InvalidTypeForListValueException
54+
* @throws Exception\ParameterIsRequiredException
5255
* @param string $collectionId
56+
* @param array<string,mixed> $query
5357
* @return BunnyClientResponseInterface
5458
* @param int $libraryId
5559
*/
5660
public function getCollection(
5761
int $libraryId,
5862
string $collectionId,
63+
array $query = [],
5964
): BunnyClientResponseInterface {
6065
$endpoint = new GetCollection();
6166

67+
ParameterValidator::validate($query, $endpoint->getQuery());
68+
6269
return $this->client->request(
6370
endpoint: $endpoint,
6471
parameters: [$libraryId, $collectionId],
72+
query: $query,
6573
);
6674
}
6775

0 commit comments

Comments
 (0)