|
| 1 | +## 7.x |
| 2 | + |
| 3 | +This release comes with breaking changes for the usability of the library. |
| 4 | + |
| 5 | +Back in release [`6.0`](https://github.com/ToshY/BunnyNet-PHP/releases/tag/6.0.0) I introduced compatibility with OpenAPI specifications. After further research and consideration, I realised that the models that were generated should be enough for the end user to create a request with, making the existing API classes (`BaseAPI`, `EdgeScriptingAPI`, `EdgeStorageAPI`, `LoggingAPI`, `ShieldAPI` and `StreamAPI`) obsolete if the users have a single entrypoint that could be used instead, which eventually became the `BunnyHttpClient`. |
| 6 | + |
| 7 | +> [!CAUTION] |
| 8 | +> Due to the nature of this release, I cannot guarantee this list of breaking changes is complete. Thank you for your understanding. |
| 9 | +
|
| 10 | +### ‼️ Breaking changes |
| 11 | + |
| 12 | +#### `BunnyHttpClient` |
| 13 | + |
| 14 | +All requests will now have to be made using the `ToshY\BunnyNet\BunnyHttpClient` (previously `ToshY\BunnyNet\Client\BunnyClient`), which now requires the `apiKey` and |
| 15 | +`baseUrl` to be set when constructing. |
| 16 | + |
| 17 | +**Example** |
| 18 | +```php |
| 19 | +<?php |
| 20 | + |
| 21 | +require 'vendor/autoload.php'; |
| 22 | + |
| 23 | +use ToshY\BunnyNet\BunnyHttpClient; |
| 24 | +use ToshY\BunnyNet\Enum\Endpoint; |
| 25 | + |
| 26 | +$bunnyHttpClient = new BunnyHttpClient( |
| 27 | + client: new \Symfony\Component\HttpClient\Psr18Client(), |
| 28 | + // Provide the account API key. |
| 29 | + apiKey: '2cebf4f8-4bff-429f-86f6-bce2c2163d7e89fb0a86-a1b2-463c-a142-11eba8811989', |
| 30 | + baseUrl: Endpoint::BASE |
| 31 | +); |
| 32 | +``` |
| 33 | + |
| 34 | +| **6.x** | **7.x** | **7.x signature notes** | |
| 35 | +|-------------------------------------|----------------------------------|-------------------------------------------| |
| 36 | +| `ToshY\BunnyNet\Client\BunnyClient` | `ToshY\BunnyNet\BunnyHttpClient` | Requires `apiKey` and `baseUrl` to be set | |
| 37 | + |
| 38 | +#### Models |
| 39 | + |
| 40 | +The `BunnyHttpClient` now has a public `request` method that accepts any model implementing `ModelInterface`. |
| 41 | + |
| 42 | +**Example** |
| 43 | +```php |
| 44 | +$bunnyHttpClient->request( |
| 45 | + new \ToshY\BunnyNet\Model\Api\Base\AbuseCase\ListAbuseCases( |
| 46 | + query: [ |
| 47 | + 'page' => 1, |
| 48 | + 'perPage' => 1000, |
| 49 | + ], |
| 50 | + ) |
| 51 | +) |
| 52 | +``` |
| 53 | + |
| 54 | +All publicly usable models can be found under the [`\ToshY\BunnyNet\Model\Api`](https://github.com/ToshY/BunnyNet-PHP/blob/master/src/Model/Api) namespace. |
| 55 | + |
| 56 | +> [!NOTE] |
| 57 | +> Examples have been updated in the [documentation](https://toshy.github.io/BunnyNet-PHP/). |
| 58 | +
|
| 59 | +#### `ImageProcessor` & `TokenAuthenitcation` |
| 60 | + |
| 61 | +The `ImageProcessor` and `TokenAuthentication` have been renamed by prefixing it with `Bunny`. |
| 62 | + |
| 63 | +| **6.x** | **7.x** | **7.x signature notes** | |
| 64 | +|--------------------------------------|--------------------------------------|-----------------------------| |
| 65 | +| `ToshY\BunnyNet\ImageProcessor` | `ToshY\BunnyNet\BunnyImageProcessor` | `generate` method is static | |
| 66 | +| `ToshY\BunnyNet\TokenAuthentication` | `ToshY\BunnyNet\BunnyTokenAuthentication` | | |
| 67 | + |
| 68 | +#### `BunnyValidator` |
| 69 | + |
| 70 | +The `BunnyValidator` was introduced in [`6.1`](https://github.com/ToshY/BunnyNet-PHP/releases/tag/6.1.0) as an initial way of making validation optional and/or more flexible. Up until now, the validator was always used by the API classes. |
| 71 | + |
| 72 | +With this release, the `BunnyValidator` has become optional, no longer is used by default and separated from the formerly known API classes. |
| 73 | + |
| 74 | +**Example** |
| 75 | +```php |
| 76 | +$bunnyValidator = new BunnyValidator(); |
| 77 | + |
| 78 | +// Construct the payload |
| 79 | +$payload = new TranscribeVideo( |
| 80 | + libraryId: 1, |
| 81 | + videoId: 'e7e9b99a-ea2a-434a-b200-f6615e7b6abd', |
| 82 | + query: [ |
| 83 | + 'language' => 'fi', |
| 84 | + 'force' => true, |
| 85 | + ], |
| 86 | + body: [ |
| 87 | + 'targetLanguages' => [ |
| 88 | + 'fi', |
| 89 | + 'jp' |
| 90 | + ], |
| 91 | + 'generateTitle' => true, |
| 92 | + 'generateDescription' => true, |
| 93 | + 'sourceLanguage' => 'en', |
| 94 | + ], |
| 95 | +); |
| 96 | + |
| 97 | +// Perform validation and catch if necessary |
| 98 | +try { |
| 99 | + $bunnyValidator->query($payload); |
| 100 | + $bunnyValidator->body($payload); |
| 101 | +} catch (BunnyValidatorExceptionInterface) { |
| 102 | + // ... |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +| **6.x** | **7.x** | |
| 107 | +|--------------------------------------------|---------------------------------| |
| 108 | +| `ToshY\BunnyNet\Validation\BunnyValidator` | `ToshY\BunnyNet\BunnyValidator` | |
| 109 | + |
| 110 | + |
| 111 | +> [!NOTE] |
| 112 | +> Usage examples for the `BunnyValidator` have been added to the [documentation](https://toshy.github.io/BunnyNet-PHP/validation/). |
| 113 | +
|
| 114 | +#### Naming coding standards |
| 115 | + |
| 116 | +All classes (and namespaces) have been updated according to the latest [coding standards](https://github.com/php/policies/blob/06ef24434942f3b09241ccbde124b83ca8a18042/coding-standards-and-naming.rst?plain=1#L26), where abbreviations/acronyms/initialisms have been renamed to be treated like regular words (camelcasing). |
| 117 | + |
| 118 | +> [!IMPORTANT] |
| 119 | +> The `6.x` branch will now no longer be maintained. |
| 120 | +
|
1 | 121 | ## 6.x |
2 | 122 |
|
3 | 123 | This release comes with minor breaking changes for public methods that have been removed to ensure OpenAPI specifications compatibility. |
@@ -48,6 +168,8 @@ The following bugs were discovered after the generator scripts recreated the mod |
48 | 168 | | Stream API | UPDATE | [`getOEmbed`](https://toshy.github.io/BunnyNet-PHP/stream-api/#get-oembed) | Query parameter `url` not required | |
49 | 169 |
|
50 | 170 |
|
| 171 | +The `5.x` branch will now no longer be maintained. |
| 172 | + |
51 | 173 | ### 🚀 Enhancements |
52 | 174 |
|
53 | 175 | | **Endpoint** | **Action** | **Method** | **Notes** | |
|
0 commit comments