diff --git a/CoC.md b/CoC.md index f2667c4..c0ceff6 100644 --- a/CoC.md +++ b/CoC.md @@ -130,4 +130,4 @@ For answers to common questions about this code of conduct, see the FAQ at [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html [Mozilla CoC]: https://github.com/mozilla/diversity [FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations +[translations]: https://www.contributor-covenant.org/translations \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d117910..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 api.video - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 587dc84..d768615 100644 --- a/README.md +++ b/README.md @@ -284,8 +284,6 @@ Method | HTTP request | Description ### Models - [AccessToken](docs/Model/AccessToken.md) - - [Account](docs/Model/Account.md) - - [AccountQuota](docs/Model/AccountQuota.md) - [AuthenticatePayload](docs/Model/AuthenticatePayload.md) - [BadRequest](docs/Model/BadRequest.md) - [BytesRange](docs/Model/BytesRange.md) @@ -366,4 +364,4 @@ $ BASE_URI="" API_KEY="..." vendor/bin/phpunit Please take a moment to leave a star on the client ⭐ -This helps other users to find the clients and also helps us understand which clients are most popular. Thank you! +This helps other users to find the clients and also helps us understand which clients are most popular. Thank you! \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..6c8ee71 --- /dev/null +++ b/composer.json @@ -0,0 +1,36 @@ +{ + "name": "api-video/php-api-client", + "description": "PHP client for api.video web services.", + "keywords": ["api.video"], + "homepage": "https://api.video/", + "license": "MIT", + "type": "library", + "authors": [ + { + "name": "ApiVideo", + "homepage": "https://api.video/" + } + ], + "require": { + "php": "^7.3 || ^8.0", + "ext-json": "*", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "php-http/multipart-stream-builder": "^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9", + "symfony/http-client": "^5.2", + "nyholm/psr7": "^1.4" + }, + "autoload": { + "psr-4": { + "ApiVideo\\Client\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "ApiVideo\\Client\\Tests\\": "tests/" + } + } +} diff --git a/docs/Api/CaptionsApi.md b/docs/Api/CaptionsApi.md index 7bbd404..41bb749 100644 --- a/docs/Api/CaptionsApi.md +++ b/docs/Api/CaptionsApi.md @@ -16,9 +16,6 @@ Method | HTTP request | Description Delete a caption in a specific language by providing the video ID for the video you want to delete the caption from and the language the caption is in. -```php -delete(string $videoId, string $language): void -``` ### Arguments @@ -36,22 +33,14 @@ Name | Type | Description | Example | Notes void (empty response body) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## list() Retrieve a list of available captions for the videoId you provide. -```php -list(string $videoId, array $queryParams = []): \ApiVideo\Client\Model\CaptionsListResponse -``` ### Arguments @@ -77,22 +66,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\CaptionsListResponse**](../Model/CaptionsListResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## get() Display a caption for a video in a specific language. If the language is available, the caption is returned. Otherwise, you will get a response indicating the caption was not found. Tutorials that use the [captions endpoint](https://api.video/blog/endpoints/captions). -```php -get(string $videoId, string $language): \ApiVideo\Client\Model\Caption -``` ### Arguments @@ -110,22 +91,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Caption**](../Model/Caption.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## update() To have the captions on automatically, use this PATCH to set default: true. -```php -update(string $videoId, string $language, \ApiVideo\Client\Model\CaptionsUpdatePayload $captionsUpdatePayload): \ApiVideo\Client\Model\Caption -``` ### Arguments @@ -144,22 +117,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Caption**](../Model/Caption.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## upload() Upload a VTT file to add captions to your video. Read our [captioning tutorial](https://api.video/blog/tutorials/adding-captions) for more details. -```php -upload(string $videoId, string $language, \SplFileObject $file): \ApiVideo\Client\Model\Caption -``` ### Arguments @@ -178,10 +143,5 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Caption**](../Model/Caption.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Api/ChaptersApi.md b/docs/Api/ChaptersApi.md index eb46380..c783d80 100644 --- a/docs/Api/ChaptersApi.md +++ b/docs/Api/ChaptersApi.md @@ -14,9 +14,6 @@ Method | HTTP request | Description -```php -delete(string $videoId, string $language): void -``` ### Arguments @@ -34,22 +31,14 @@ Name | Type | Description | Example | Notes void (empty response body) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## list() Retrieve a list of all chapters for a specified video. -```php -list(string $videoId, array $queryParams = []): \ApiVideo\Client\Model\ChaptersListResponse -``` ### Arguments @@ -75,22 +64,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\ChaptersListResponse**](../Model/ChaptersListResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## get() Chapters help your viewers find the sections of the video they are most interested in viewing. Tutorials that use the [chapters endpoint](https://api.video/blog/endpoints/chapters). -```php -get(string $videoId, string $language): \ApiVideo\Client\Model\Chapter -``` ### Arguments @@ -108,22 +89,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Chapter**](../Model/Chapter.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## upload() Chapters help break the video into sections. Read our [tutorial](https://api.video/blog/tutorials/adding-chapters-to-your-videos) for more details. -```php -upload(string $videoId, string $language, \SplFileObject $file): \ApiVideo\Client\Model\Chapter -``` ### Arguments @@ -142,10 +115,5 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Chapter**](../Model/Chapter.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Api/LiveStreamsApi.md b/docs/Api/LiveStreamsApi.md index a736ea8..98acd97 100644 --- a/docs/Api/LiveStreamsApi.md +++ b/docs/Api/LiveStreamsApi.md @@ -17,9 +17,6 @@ Method | HTTP request | Description -```php -delete(string $liveStreamId): void -``` ### Arguments @@ -36,22 +33,14 @@ Name | Type | Description | Example | Notes void (empty response body) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## deleteThumbnail() Send the unique identifier for a live stream to delete it from the system. -```php -deleteThumbnail(string $liveStreamId): \ApiVideo\Client\Model\LiveStream -``` ### Arguments @@ -68,22 +57,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\LiveStream**](../Model/LiveStream.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## list() With no parameters added to the url, this will return all livestreams. Query by name or key to limit the list. -```php -list(array $queryParams = []): \ApiVideo\Client\Model\LiveStreamListResponse -``` ### Arguments @@ -111,22 +92,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\LiveStreamListResponse**](../Model/LiveStreamListResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## get() Supply a LivestreamId, and you'll get all the details for streaming into, and watching the livestream. Tutorials that use the [show livestream endpoint](https://api.video/blog/endpoints/live-stream-status). -```php -get(string $liveStreamId): \ApiVideo\Client\Model\LiveStream -``` ### Arguments @@ -143,22 +116,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\LiveStream**](../Model/LiveStream.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## update() Use this endpoint to update the player, or to turn recording on/off (saving a copy of the livestream). NOTE: If the livestream is actively streaming, changing the recording status will only affect the NEXT stream. The public=false 'private livestream' is available as a BETA feature, and should be limited to livestreams of 3,000 viewers or fewer. -```php -update(string $liveStreamId, \ApiVideo\Client\Model\LiveStreamUpdatePayload $liveStreamUpdatePayload): \ApiVideo\Client\Model\LiveStream -``` ### Arguments @@ -176,22 +141,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\LiveStream**](../Model/LiveStream.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## create() -A live stream will give you the 'connection point' to RTMP your video stream to api.video. It will also give you the details for viewers to watch the same livestream. The public=false 'private livestream' is available as a BETA feature, and should be limited to livestreams of 3,000 viewers or fewer. See our [Live Stream Tutorial](https://api.video/blog/tutorials/live-stream-tutorial) for a walkthrough of this API with OBS. Your RTMP endpoint for the livestream is rtmp://broadcast.api.video/s/{streamKey} Tutorials that [create live streams](https://api.video/blog/endpoints/live-create). +A live stream will give you the 'connection point' to RTMP your video stream to api.video. It will also give you the details for viewers to watch the same livestream. The public=false 'private livestream' is available as a BETA feature, and should be limited to livestreams of 3,000 viewers or fewer. See our [Live Stream Tutorial](https://api.video/blog/tutorials/live-stream-tutorial) for a walkthrough of this API with OBS. Your RTMP endpoint for the livestream is rtmp://broadcast.api.video/s/{streamKey} Tutorials that [create live streams](https://api.video/blog/endpoints/live-create). -```php -create(\ApiVideo\Client\Model\LiveStreamCreationPayload $liveStreamCreationPayload): \ApiVideo\Client\Model\LiveStream -``` ### Arguments @@ -208,22 +165,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\LiveStream**](../Model/LiveStream.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## uploadThumbnail() Upload an image to use as a backdrop for your livestream. Tutorials that [update live stream thumbnails](https://api.video/blog/endpoints/live-upload-a-thumbnail). -```php -uploadThumbnail(string $liveStreamId, \SplFileObject $file): \ApiVideo\Client\Model\LiveStream -``` ### Arguments @@ -241,10 +190,5 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\LiveStream**](../Model/LiveStream.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Api/PlayerThemesApi.md b/docs/Api/PlayerThemesApi.md index 399ed71..a6ab34a 100644 --- a/docs/Api/PlayerThemesApi.md +++ b/docs/Api/PlayerThemesApi.md @@ -18,9 +18,6 @@ Method | HTTP request | Description Delete a player if you no longer need it. You can delete any player that you have the player ID for. -```php -delete(string $playerId): void -``` ### Arguments @@ -37,21 +34,13 @@ Name | Type | Description | Example | Notes void (empty response body) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## deleteLogo() -```php -deleteLogo(string $playerId): void -``` ### Arguments @@ -68,22 +57,14 @@ Name | Type | Description | Example | Notes void (empty response body) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## list() Retrieve a list of all the players you created, as well as details about each one. Tutorials that use the [player endpoint](https://api.video/blog/endpoints/player). -```php -list(array $queryParams = []): \ApiVideo\Client\Model\PlayerThemesListResponse -``` ### Arguments @@ -109,22 +90,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\PlayerThemesListResponse**](../Model/PlayerThemesListResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## get() Use a player ID to retrieve details about the player and display it for viewers. -```php -get(string $playerId): \ApiVideo\Client\Model\PlayerTheme -``` ### Arguments @@ -141,22 +114,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\PlayerTheme**](../Model/PlayerTheme.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## update() Use a player ID to update specific details for a player. NOTE: It may take up to 10 min before the new player configuration is available from our CDN. -```php -update(string $playerId, \ApiVideo\Client\Model\PlayerThemeUpdatePayload $playerThemeUpdatePayload): \ApiVideo\Client\Model\PlayerTheme -``` ### Arguments @@ -174,22 +139,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\PlayerTheme**](../Model/PlayerTheme.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## create() Create a player for your video, and customise it. -```php -create(\ApiVideo\Client\Model\PlayerThemeCreationPayload $playerThemeCreationPayload): \ApiVideo\Client\Model\PlayerTheme -``` ### Arguments @@ -206,22 +163,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\PlayerTheme**](../Model/PlayerTheme.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## uploadLogo() -The uploaded image maximum size should be 200x100 and its weight should be 200KB. It will be scaled down to 30px height and converted to PNG to be displayed in the player. +The uploaded image maximum size should be 200x100 and its weight should be 200KB. It will be scaled down to 30px height and converted to PNG to be displayed in the player. -```php -uploadLogo(string $playerId, \SplFileObject $file, string $link = null): \ApiVideo\Client\Model\PlayerTheme -``` ### Arguments @@ -240,10 +189,5 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\PlayerTheme**](../Model/PlayerTheme.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Api/RawStatisticsApi.md b/docs/Api/RawStatisticsApi.md index 334b850..7131bd7 100644 --- a/docs/Api/RawStatisticsApi.md +++ b/docs/Api/RawStatisticsApi.md @@ -13,9 +13,6 @@ Method | HTTP request | Description -```php -listLiveStreamSessions(string $liveStreamId, array $queryParams = []): \ApiVideo\Client\Model\RawStatisticsListLiveStreamAnalyticsResponse -``` ### Arguments @@ -29,7 +26,7 @@ Note: `$queryParams` argument is an associative array with the keys listed below Name | Type | Description | Example | Notes ------------- | ------------- | ------------- | ------------- | ------------- - `period` | **string**| Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\" | `2019-01-01` | [optional] + `period` | **string**| Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\" | `2019-01-01` | [optional] `currentPage` | **int**| Choose the number of search results to return per page. Minimum value: 1 | `2` | [optional] [default to 1] `pageSize` | **int**| Results per page. Allowed values 1-100, default is 25. | `30` | [optional] [default to 25] @@ -42,22 +39,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\RawStatisticsListLiveStreamAnalyticsResponse**](../Model/RawStatisticsListLiveStreamAnalyticsResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## listSessionEvents() Useful to track and measure video's engagement. -```php -listSessionEvents(string $sessionId, array $queryParams = []): \ApiVideo\Client\Model\RawStatisticsListPlayerSessionEventsResponse -``` ### Arguments @@ -83,22 +72,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\RawStatisticsListPlayerSessionEventsResponse**](../Model/RawStatisticsListPlayerSessionEventsResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## listVideoSessions() Retrieve all available user sessions for a specific video. Tutorials that use the [analytics endpoint](https://api.video/blog/endpoints/analytics). -```php -listVideoSessions(string $videoId, array $queryParams = []): \ApiVideo\Client\Model\RawStatisticsListSessionsResponse -``` ### Arguments @@ -112,8 +93,8 @@ Note: `$queryParams` argument is an associative array with the keys listed below Name | Type | Description | Example | Notes ------------- | ------------- | ------------- | ------------- | ------------- - `period` | **string**| Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15 | `'period_example'` | [optional] - `metadata` | [**map[string,string]**](../Model/string.md)| Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with. | `metadata[Author]=John Doe&metadata[Format]=Tutorial` | [optional] + `period` | **string**| Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15 | `'period_example'` | [optional] + `metadata` | [**map[string,string]**](../Model/string.md)| Metadata and [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) filter. Send an array of key value pairs you want to filter sessios with. | `metadata[Author]=John Doe&metadata[Format]=Tutorial` | [optional] `currentPage` | **int**| Choose the number of search results to return per page. Minimum value: 1 | `2` | [optional] [default to 1] `pageSize` | **int**| Results per page. Allowed values 1-100, default is 25. | `30` | [optional] [default to 25] @@ -126,10 +107,5 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\RawStatisticsListSessionsResponse**](../Model/RawStatisticsListSessionsResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Api/UploadTokensApi.md b/docs/Api/UploadTokensApi.md index c550531..44cac53 100644 --- a/docs/Api/UploadTokensApi.md +++ b/docs/Api/UploadTokensApi.md @@ -15,9 +15,6 @@ Method | HTTP request | Description Delete an existing upload token. This is especially useful for tokens you may have created that do not expire. -```php -deleteToken(string $uploadToken): void -``` ### Arguments @@ -34,22 +31,14 @@ Name | Type | Description | Example | Notes void (empty response body) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## list() A delegated token is used to allow secure uploads without exposing your API key. Use this endpoint to retrieve a list of all currently active delegated tokens. Tutorials using [delegated upload](https://api.video/blog/endpoints/delegated-upload). -```php -list(array $queryParams = []): \ApiVideo\Client\Model\TokenListResponse -``` ### Arguments @@ -75,22 +64,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\TokenListResponse**](../Model/TokenListResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## getToken() You can retrieve details about a specific upload token if you have the unique identifier for the upload token. Add it in the path of the endpoint. Details include time-to-live (ttl), when the token was created, and when it will expire. -```php -getToken(string $uploadToken): \ApiVideo\Client\Model\UploadToken -``` ### Arguments @@ -107,22 +88,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\UploadToken**](../Model/UploadToken.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## createToken() Use this endpoint to generate an upload token. You can use this token to authenticate video uploads while keeping your API key safe. Tutorials using [delegated upload](https://api.video/blog/endpoints/delegated-upload). -```php -createToken(\ApiVideo\Client\Model\TokenCreationPayload $tokenCreationPayload): \ApiVideo\Client\Model\UploadToken -``` ### Arguments @@ -139,10 +112,5 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\UploadToken**](../Model/UploadToken.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Api/VideosApi.md b/docs/Api/VideosApi.md index fdf40c4..9693ba9 100644 --- a/docs/Api/VideosApi.md +++ b/docs/Api/VideosApi.md @@ -21,9 +21,6 @@ Method | HTTP request | Description If you do not need a video any longer, you can send a request to delete it. All you need is the videoId. Tutorials using [video deletion](https://api.video/blog/endpoints/video-delete). -```php -delete(string $videoId): void -``` ### Arguments @@ -40,22 +37,14 @@ Name | Type | Description | Example | Notes void (empty response body) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## get() This call provides the same JSON information provided on video creation. For private videos, it will generate a unique token url. Use this to retrieve any details you need about a video, or set up a private viewing URL. Tutorials using [video GET](https://api.video/blog/endpoints/video-get). -```php -get(string $videoId): \ApiVideo\Client\Model\Video -``` ### Arguments @@ -72,22 +61,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Video**](../Model/Video.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## getStatus() -This API provides upload status & encoding status to determine when the video is uploaded or ready to playback. Once encoding is completed, the response also lists the available stream qualities. Tutorials using [video status](https://api.video/blog/endpoints/video-status). +This API provides upload status & encoding status to determine when the video is uploaded or ready to playback. Once encoding is completed, the response also lists the available stream qualities. Tutorials using [video status](https://api.video/blog/endpoints/video-status). -```php -getStatus(string $videoId): \ApiVideo\Client\Model\VideoStatus -``` ### Arguments @@ -104,21 +85,41 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\VideoStatus**](../Model/VideoStatus.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## list() -Requests to this endpoint return a list of your videos (with all their details). With no parameters added to this query, the API returns all videos. You can filter what videos the API returns using the parameters described below. We have [several tutorials](https://api.video/blog/endpoints/video-list) that demonstrate this endpoint. +Requests to this endpoint return a list of your videos (with all their details). With no parameters added to this query, the API returns all videos. You can filter what videos the API returns using the parameters described below. We have [several tutorials](https://api.video/blog/endpoints/video-list) that demonstrate this endpoint. + +### Example ```php -list(array $queryParams = []): \ApiVideo\Client\Model\VideosListResponse +videos()->list([]); + $allVideos = array_merge($allVideos, $currentPage->getData()); +} while($currentPage->getPagination()->getCurrentPage() < $currentPage->getPagination()->getPagesTotal()); + +// list videos that have all the given tags (only first results page) +$videosWithTag = $client->videos()->list(['tags' => ['TAG2','TAG1']]); + +// list videos that have all the given metadata values (only first results page) +$videosWithMetadata = $client->videos()->list(['metadata' => ['key1' => 'key1value1', 'key2' => 'key2value1']]); + ``` ### Arguments @@ -133,7 +134,7 @@ Name | Type | Description | Example | Notes ------------- | ------------- | ------------- | ------------- | ------------- `title` | **string**| The title of a specific video you want to find. The search will match exactly to what term you provide and return any videos that contain the same term as part of their titles. | `My Video.mp4` | [optional] `tags` | [**string[]**](../Model/string.md)| A tag is a category you create and apply to videos. You can search for videos with particular tags by listing one or more here. Only videos that have all the tags you list will be returned. | `["captions", "dialogue"]` | [optional] - `metadata` | [**map[string,string]**](../Model/string.md)| Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter. | `metadata[Author]=John Doe&metadata[Format]=Tutorial` | [optional] + `metadata` | [**map[string,string]**](../Model/string.md)| Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair. | `metadata[Author]=John Doe&metadata[Format]=Tutorial` | [optional] `description` | **string**| If you described a video with a term or sentence, you can add it here to return videos containing this string. | `New Zealand` | [optional] `liveStreamId` | **string**| If you know the ID for a live stream, you can retrieve the stream by adding the ID for it here. | `li400mYKSgQ6xs7taUeSaEKr` | [optional] `sortBy` | **string**| Allowed: publishedAt, title. You can search by the time videos were published at, or by title. | `publishedAt` | [optional] @@ -150,21 +151,40 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\VideosListResponse**](../Model/VideosListResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## update() Use this endpoint to update the parameters associated with your video. The video you are updating is determined by the video ID you provide in the path. For each parameter you want to update, include the update in the request body. NOTE: If you are updating an array, you must provide the entire array as what you provide here overwrites what is in the system rather than appending to it. Tutorials using [video update](https://api.video/blog/endpoints/video-update). +### Example + ```php -update(string $videoId, \ApiVideo\Client\Model\VideoUpdatePayload $videoUpdatePayload): \ApiVideo\Client\Model\Video +videos()->update("vi6DEWhlgoHU3Ig5tgPlYkBc", (new VideoUpdatePayload()) + ->setTitle("The new title") + ->setPublic(false) + ->setDescription("A new description") + ->setTags(["tag1", "tag2"]) + ->setMetadata(array( + new Metadata(["key" => "aa", 'value' => "bb"]), + new Metadata(["key" => "aa2", 'value' => "bb2"])))); + ``` ### Arguments @@ -183,22 +203,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Video**](../Model/Video.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## pickThumbnail() Pick a thumbnail from the given time code. If you'd like to upload an image for your thumbnail, use the [Upload a Thumbnail](https://docs.api.video/reference#post_videos-videoid-thumbnail) endpoint. There may be a short delay for the thumbnail to update. Tutorials using [Thumbnail picking](https://api.video/blog/endpoints/video-pick-a-thumbnail). -```php -pickThumbnail(string $videoId, \ApiVideo\Client\Model\VideoThumbnailPickPayload $videoThumbnailPickPayload): \ApiVideo\Client\Model\Video -``` ### Arguments @@ -216,22 +228,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Video**](../Model/Video.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## uploadWithUploadToken() When given a token, anyone can upload a file to the URI `https://ws.api.video/upload?token=`. Example with cURL: ```curl $ curl --request POST --url 'https://ws.api.video/upload?token=toXXX' --header 'content-type: multipart/form-data' -F file=@video.mp4 ``` Or in an HTML form, with a little JavaScript to convert the form into JSON: ```html

``` ### Dealing with large files We have created a tutorial to walk through the steps required. -```php -uploadWithUploadToken(string $token, \SplFileObject $file, string $contentRange = null, string $videoId = null): \ApiVideo\Client\Model\Video -``` ### Arguments @@ -251,21 +255,38 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Video**](../Model/Video.md) -### Authorization -No authorization required. -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## create() -To create a video, you create its metadata first, before adding the video file (exception - when using an existing HTTP source). * Videos are public by default. [Learn about Private videos](https://api.video/blog/tutorials/tutorial-private-videos) * Up to 6 responsive video streams will be created (from 240p to 4k) * Mp4 encoded versions are created at the highest quality (max 1080p) by default. * Panoramic videos are for videos recorded in 360 degrees. You can toggle this after your 360 video upload. * Searchable parameters: title, description, tags and metadata ```shell $ curl https://ws.api.video/videos \\ -H 'Authorization: Bearer {access_token} \\ -d '{\"title\":\"My video\", \"description\":\"so many details\", \"mp4Support\":true }' ``` ### add an URL to upload on creation You can also create a video directly from a video hosted on a third-party server by giving its URI in `source` parameter: ```shell $ curl https://ws.api.video/videos \\ -H 'Authorization: Bearer {access_token} \\ -d '{\"source\":\"http://uri/to/video.mp4\", \"title\":\"My video\"}' ``` In this case, the service will respond `202 Accepted` and download the video asynchronously. ### Track users with Dynamic Metadata Metadata values can be a key:value where the values are predefined, but Dynamic metadata allows you to enter *any* value for a defined key. To defined a dynamic metadata pair use: ``` \"metadata\":[{\"dynamicKey\": \"__dynamicKey__\"}] ``` The double underscore on both sides of the value allows any variable to be added for a given video session. Added the the url you might have: ``` ``` This video session will be tagged as watched by Doug - allowing for in-depth analysis on how each viewer interacts with the videos. We have tutorials on: * [Creating and uploading videos](https://api.video/blog/tutorials/video-upload-tutorial) * [Uploading large videos](https://api.video/blog/tutorials/video-upload-tutorial-large-videos) * [Using tags with videos](https://api.video/blog/tutorials/video-tagging-best-practices) * [Private videos](https://api.video/blog/tutorials/tutorial-private-videos) * [Using Dynamic Metadata](https://api.video/blog/tutorials/dynamic-metadata) * Full list of [tutorials](https://api.video/blog/endpoints/video-create) that demonstrate this endpoint. +## We have tutorials on: * [Creating and uploading videos](https://api.video/blog/tutorials/video-upload-tutorial) * [Uploading large videos](https://api.video/blog/tutorials/video-upload-tutorial-large-videos) * [Using tags with videos](https://api.video/blog/tutorials/video-tagging-best-practices) * [Private videos](https://api.video/blog/tutorials/tutorial-private-videos) * [Using Dynamic Metadata](https://api.video/blog/tutorials/dynamic-metadata) * Full list of [tutorials](https://api.video/blog/endpoints/video-create) that demonstrate this endpoint. + +### Example ```php -create(\ApiVideo\Client\Model\VideoCreationPayload $videoCreationPayload): \ApiVideo\Client\Model\Video +videos()->create((new VideoCreationPayload()) + ->setTitle('Video B') + ->setTags(array("TAG1", "TAG2")) + ->setMetadata(array( + new Metadata(['key' => 'key1', 'value' => 'key1value1']), + new Metadata(['key' => 'key2', 'value' => 'key2value1'])))); + ``` ### Arguments @@ -283,21 +304,44 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Video**](../Model/Video.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## upload() -To upload a video to the videoId you created. Replace {videoId} with the id you'd like to use, {access_token} with your token, and /path/to/video.mp4 with the path to the video you'd like to upload. You can only upload your video to the videoId once. ```bash curl https://ws.api.video/videos/{videoId}/source \\ -H 'Authorization: Bearer {access_token}' \\ -F file=@/path/to/video.mp4 ``` Tutorials using [video upload](https://api.video/blog/endpoints/video-upload) +To upload a video to the videoId you created. Replace {videoId} with the id you'd like to use, {access_token} with your token, and /path/to/video.mp4 with the path to the video you'd like to upload. You can only upload your video to the videoId once. ```bash curl https://ws.api.video/videos/{videoId}/source \\ -H 'Authorization: Bearer {access_token}' \\ -F file=@/path/to/video.mp4 ``` Tutorials using [video upload](https://api.video/blog/endpoints/video-upload). + +### Example ```php -upload(string $videoId, \SplFileObject $file, string $contentRange = null): \ApiVideo\Client\Model\Video +videos()->create((new VideoCreationPayload())->setTitle('Uploaded video')); +$client->videos()->upload($myVideo->getVideoId(), new SplFileObject(__DIR__ . '/../../../tests/resources/558k.mp4')); + +// create a new video & upload a video file using progressive upload (the file is uploaded by parts) +$myVideo2 = $client->videos()->create((new VideoCreationPayload())->setTitle('Uploaded video (progressive upload)')); + +$progressiveSession = $client->videos()->createUploadProgressiveSession($myVideo2->getVideoId()); + +$progressiveSession->uploadPart(new SplFileObject(__DIR__ . '/../../../tests/resources/10m.mp4.part.a')); +$progressiveSession->uploadPart(new SplFileObject(__DIR__ . '/../../../tests/resources/10m.mp4.part.b')); + +$progressiveSession->uploadLastPart(new SplFileObject(__DIR__ . '/../../../tests/resources/10m.mp4.part.c')); + ``` ### Arguments @@ -317,22 +361,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Video**](../Model/Video.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## uploadThumbnail() -The thumbnail is the poster that appears in the player window before video playback begins. This endpoint allows you to upload an image for the thumbnail. To select a still frame from the video using a time stamp, use [Pick a Thumbnail](https://docs.api.video/reference#patch_videos-videoid-thumbnail) to pick a time in the video. Note: There may be a short delay before the new thumbnail is delivered to our CDN. Tutorials using [Thumbnail upload](https://api.video/blog/endpoints/videos-upload-a-thumbnail). +The thumbnail is the poster that appears in the player window before video playback begins. This endpoint allows you to upload an image for the thumbnail. To select a still frame from the video using a time stamp, use [Pick a Thumbnail](https://docs.api.video/reference#patch_videos-videoid-thumbnail) to pick a time in the video. Note: There may be a short delay before the new thumbnail is delivered to our CDN. Tutorials using [Thumbnail upload](https://api.video/blog/endpoints/videos-upload-a-thumbnail). -```php -uploadThumbnail(string $videoId, \SplFileObject $file): \ApiVideo\Client\Model\Video -``` ### Arguments @@ -350,10 +386,5 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Video**](../Model/Video.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Api/WebhooksApi.md b/docs/Api/WebhooksApi.md index 338a8f5..0f794f9 100644 --- a/docs/Api/WebhooksApi.md +++ b/docs/Api/WebhooksApi.md @@ -15,9 +15,6 @@ Method | HTTP request | Description This endpoint will delete the indicated webhook. -```php -delete(string $webhookId): void -``` ### Arguments @@ -34,22 +31,14 @@ Name | Type | Description | Example | Notes void (empty response body) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## get() This call provides the same JSON information provided on Webjhook creation. -```php -get(string $webhookId): \ApiVideo\Client\Model\Webhook -``` ### Arguments @@ -66,22 +55,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Webhook**](../Model/Webhook.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## list() Requests to this endpoint return a list of your webhooks (with all their details). You can filter what the webhook list that the API returns using the parameters described below. -```php -list(array $queryParams = []): \ApiVideo\Client\Model\WebhooksListResponse -``` ### Arguments @@ -106,22 +87,14 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\WebhooksListResponse**](../Model/WebhooksListResponse.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) ## create() -Webhooks can push notifications to your server, rather than polling api.video for changes. We currently offer four events: * ```video.encoding.quality.completed``` When a new video is uploaded into your account, it will be encoded into several different HLS sizes/bitrates. When each version is encoded, your webhook will get a notification. It will look like ```{ \\\"type\\\": \\\"video.encoding.quality.completed\\\", \\\"emittedAt\\\": \\\"2021-01-29T16:46:25.217+01:00\\\", \\\"videoId\\\": \\\"viXXXXXXXX\\\", \\\"encoding\\\": \\\"hls\\\", \\\"quality\\\": \\\"720p\\\"} ```. This request says that the 720p HLS encoding was completed. * ```live-stream.broadcast.started``` When a livestream begins broadcasting, the broadcasting parameter changes from false to true, and this webhook fires. * ```live-stream.broadcast.ended``` This event fores when the livestream has finished broadcasting, and the broadcasting parameter flips from false to true. * ```video.source.recorded``` This event is similar to ```video.encoding.quality.completed```, but tells you if a livestream has been recorded as a VOD. +Webhooks can push notifications to your server, rather than polling api.video for changes. We currently offer four events: * ```video.encoding.quality.completed``` When a new video is uploaded into your account, it will be encoded into several different HLS sizes/bitrates. When each version is encoded, your webhook will get a notification. It will look like ```{ \\\"type\\\": \\\"video.encoding.quality.completed\\\", \\\"emittedAt\\\": \\\"2021-01-29T16:46:25.217+01:00\\\", \\\"videoId\\\": \\\"viXXXXXXXX\\\", \\\"encoding\\\": \\\"hls\\\", \\\"quality\\\": \\\"720p\\\"} ```. This request says that the 720p HLS encoding was completed. * ```live-stream.broadcast.started``` When a livestream begins broadcasting, the broadcasting parameter changes from false to true, and this webhook fires. * ```live-stream.broadcast.ended``` This event fores when the livestream has finished broadcasting, and the broadcasting parameter flips from false to true. * ```video.source.recorded``` This event is similar to ```video.encoding.quality.completed```, but tells you if a livestream has been recorded as a VOD. -```php -create(\ApiVideo\Client\Model\WebhooksCreationPayload $webhooksCreationPayload): \ApiVideo\Client\Model\Webhook -``` ### Arguments @@ -138,10 +111,5 @@ Name | Type | Description | Example | Notes [**\ApiVideo\Client\Model\Webhook**](../Model/Webhook.md) -### Authorization -[bearerAuth](../../README.md) -[[Back to top]](#) [[Back to API list]](../../README.md#endpoints) -[[Back to Model list]](../../README.md#models) -[[Back to README]](../../README.md) diff --git a/docs/Model/Account.md b/docs/Model/Account.md deleted file mode 100644 index a981161..0000000 --- a/docs/Model/Account.md +++ /dev/null @@ -1,11 +0,0 @@ -# # Account - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**quota** | [**\ApiVideo\Client\Model\AccountQuota**](AccountQuota.md) | | [optional] -**features** | **string[]** | Deprecated. What features are enabled for your account. Choices include: app.dynamic_metadata - the ability to dynamically tag videos to better segment and understand your audiences, app.event_log - the ability to create and retrieve a log detailing how your videos were interacted with, player.white_label - the ability to customise your player, stats.player_events - the ability to see statistics about how your player is being used, transcode.mp4_support - the ability to reformat content into mp4 using the H264 codec. | [optional] -**environment** | **string** | Deprecated. Whether you are using your production or sandbox API key will impact what environment is displayed here, as well as stats and features information. If you use your sandbox key, the environment is \"sandbox.\" If you use your production key, the environment is \"production.\" | [optional] - -[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/AccountQuota.md b/docs/Model/AccountQuota.md deleted file mode 100644 index d26ecfe..0000000 --- a/docs/Model/AccountQuota.md +++ /dev/null @@ -1,11 +0,0 @@ -# # AccountQuota - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**quotaUsed** | **float** | Deprecated | [optional] -**quotaRemaining** | **float** | Deprecated | [optional] -**quotaTotal** | **float** | Deprecated | [optional] - -[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/TokenCreationPayload.md b/docs/Model/TokenCreationPayload.md index 6bc4142..09ab11a 100644 --- a/docs/Model/TokenCreationPayload.md +++ b/docs/Model/TokenCreationPayload.md @@ -4,6 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ttl** | **int** | Time in seconds that the token will be active. A value of 0 means that the token has no expiration date. The default is to have no expiration. | [optional] [default to 0] +**ttl** | **int** | Time in seconds that the token will be active. A value of 0 means that the token has no exipration date. The default is to have no expiration. | [optional] [default to 0] [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/Video.md b/docs/Model/Video.md index aff11f5..32d7f53 100644 --- a/docs/Model/Video.md +++ b/docs/Model/Video.md @@ -5,17 +5,17 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **videoId** | **string** | The unique identifier of the video object. | -**createdAt** | [**\DateTime**](\DateTime.md) | When an webhook was created, presented in ISO-8601 format. | [optional] +**createdAt** | [**\DateTime**](\DateTime.md) | When a video was created, presented in ISO-8601 format. | [optional] **title** | **string** | The title of the video content. | **description** | **string** | A description for the video content. | [optional] **publishedAt** | **string** | The date and time the API created the video. Date and time are provided using ISO-8601 UTC format. | [optional] **updatedAt** | [**\DateTime**](\DateTime.md) | The date and time the video was updated. Date and time are provided using ISO-8601 UTC format. | [optional] **tags** | **string[]** | One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces. | [optional] -**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | Metadata you can use to categorise and filter videos. Metadata is a list of dictionaries, where each dictionary represents a key value pair for categorising a video. | [optional] +**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | Metadata you can use to categorise and filter videos. Metadata is a list of dictionaries, where each dictionary represents a key value pair for categorising a video. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair. | [optional] **source** | [**\ApiVideo\Client\Model\VideoSource**](VideoSource.md) | | [optional] **assets** | [**\ApiVideo\Client\Model\VideoAssets**](VideoAssets.md) | | [optional] **playerId** | **string** | The id of the player that will be applied on the video. | [optional] -**public** | **bool** | Defines if the content is publicly reachable or if a unique token is needed for each play session. | [optional] +**public** | **bool** | Defines if the content is publicly reachable or if a unique token is needed for each play session. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos). | [optional] **panoramic** | **bool** | Defines if video is panoramic. | [optional] **mp4Support** | **bool** | This lets you know whether mp4 is supported. If enabled, an mp4 URL will be provided in the response for the video. | [optional] diff --git a/docs/Model/VideoCreationPayload.md b/docs/Model/VideoCreationPayload.md index 5460712..f53da6a 100644 --- a/docs/Model/VideoCreationPayload.md +++ b/docs/Model/VideoCreationPayload.md @@ -7,11 +7,11 @@ Name | Type | Description | Notes **title** | **string** | The title of your new video. | **description** | **string** | A brief description of your video. | [optional] **source** | **string** | If you add a video already on the web, this is where you enter the url for the video. | [optional] -**public** | **bool** | Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view. | [optional] [default to true] +**public** | **bool** | Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos). | [optional] [default to true] **panoramic** | **bool** | Indicates if your video is a 360/immersive video. | [optional] [default to false] **mp4Support** | **bool** | Enables mp4 version in addition to streamed version. | [optional] [default to true] **playerId** | **string** | The unique identification number for your video player. | [optional] **tags** | **string[]** | A list of tags you want to use to describe your video. | [optional] -**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. You can also just use the pairs as another way to tag and categorize your videos. | [optional] +**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. Read more on [dynamic metadata](https://api.video/blog/endpoints/dynamic-metadata). | [optional] [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/VideoThumbnailPickPayload.md b/docs/Model/VideoThumbnailPickPayload.md index a8e2ea4..ba84d8e 100644 --- a/docs/Model/VideoThumbnailPickPayload.md +++ b/docs/Model/VideoThumbnailPickPayload.md @@ -4,6 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**timecode** | **string** | Frame in video to be used as a placeholder before the video plays. Example: '\"00:01:00.000\" for 1 minute into the video.' Valid Patterns: \"hh:mm:ss.ms\" \"hh:mm:ss:frameNumber\" \"124\" (integer value is reported as seconds) If selection is out of range, \"00:00:00.00\" will be chosen. | +**timecode** | **string** | Frame in video to be used as a placeholder before the video plays. Example: '\"00:01:00.000\" for 1 minute into the video.' Valid Patterns: \"hh:mm:ss.ms\" \"hh:mm:ss:frameNumber\" \"124\" (integer value is reported as seconds) If selection is out of range, \"00:00:00.00\" will be chosen. | [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/docs/Model/VideoUpdatePayload.md b/docs/Model/VideoUpdatePayload.md index 9447887..157280b 100644 --- a/docs/Model/VideoUpdatePayload.md +++ b/docs/Model/VideoUpdatePayload.md @@ -7,10 +7,10 @@ Name | Type | Description | Notes **playerId** | **string** | The unique ID for the player you want to associate with your video. | [optional] **title** | **string** | The title you want to use for your video. | [optional] **description** | **string** | A brief description of the video. | [optional] -**public** | **bool** | Whether the video is publicly available or not. False means it is set to private. | [optional] +**public** | **bool** | Whether the video is publicly available or not. False means it is set to private. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos). | [optional] **panoramic** | **bool** | Whether the video is a 360 degree or immersive video. | [optional] **mp4Support** | **bool** | Whether the player supports the mp4 format. | [optional] **tags** | **string[]** | A list of terms or words you want to tag the video with. Make sure the list includes all the tags you want as whatever you send in this list will overwrite the existing list for the video. | [optional] -**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. | [optional] +**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair. | [optional] [[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/src/Api/CaptionsApi.php b/src/Api/CaptionsApi.php index 41db799..1924974 100644 --- a/src/Api/CaptionsApi.php +++ b/src/Api/CaptionsApi.php @@ -21,6 +21,7 @@ use ApiVideo\Client\Request; use ApiVideo\Client\ObjectSerializer; use ApiVideo\Client\VideoUploader; +use ApiVideo\Client\ProgressiveUploadSession; /** * @category Class @@ -118,6 +119,7 @@ private function buildDeleteRequest(string $videoId, string $language): Request ); } + /** * List video captions * @@ -197,6 +199,7 @@ private function buildListRequest(string $videoId, array $queryParams = []): Req ); } + /** * Show a caption * @@ -276,6 +279,7 @@ private function buildGetRequest(string $videoId, string $language): Request ); } + /** * Update caption * @@ -366,6 +370,7 @@ private function buildUpdateRequest(string $videoId, string $language, \ApiVideo ); } + /** * Upload a caption * @@ -472,4 +477,5 @@ private function buildUploadRequest(string $videoId, string $language, \SplFileO ); } + } diff --git a/src/Api/ChaptersApi.php b/src/Api/ChaptersApi.php index 35c6056..6381c14 100644 --- a/src/Api/ChaptersApi.php +++ b/src/Api/ChaptersApi.php @@ -21,6 +21,7 @@ use ApiVideo\Client\Request; use ApiVideo\Client\ObjectSerializer; use ApiVideo\Client\VideoUploader; +use ApiVideo\Client\ProgressiveUploadSession; /** * @category Class @@ -118,6 +119,7 @@ private function buildDeleteRequest(string $videoId, string $language): Request ); } + /** * List video chapters * @@ -197,6 +199,7 @@ private function buildListRequest(string $videoId, array $queryParams = []): Req ); } + /** * Show a chapter * @@ -276,6 +279,7 @@ private function buildGetRequest(string $videoId, string $language): Request ); } + /** * Upload a chapter * @@ -382,4 +386,5 @@ private function buildUploadRequest(string $videoId, string $language, \SplFileO ); } + } diff --git a/src/Api/LiveStreamsApi.php b/src/Api/LiveStreamsApi.php index 6d699aa..bf31805 100644 --- a/src/Api/LiveStreamsApi.php +++ b/src/Api/LiveStreamsApi.php @@ -21,6 +21,7 @@ use ApiVideo\Client\Request; use ApiVideo\Client\ObjectSerializer; use ApiVideo\Client\VideoUploader; +use ApiVideo\Client\ProgressiveUploadSession; /** * @category Class @@ -102,6 +103,7 @@ private function buildDeleteRequest(string $liveStreamId): Request ); } + /** * Delete a thumbnail * @@ -165,6 +167,7 @@ private function buildDeleteThumbnailRequest(string $liveStreamId): Request ); } + /** * List all live streams * @@ -252,6 +255,7 @@ private function buildListRequest(array $queryParams = []): Request ); } + /** * Show live stream * @@ -315,6 +319,7 @@ private function buildGetRequest(string $liveStreamId): Request ); } + /** * Update a live stream * @@ -389,6 +394,7 @@ private function buildUpdateRequest(string $liveStreamId, \ApiVideo\Client\Model ); } + /** * Create live stream * @@ -447,6 +453,7 @@ private function buildCreateRequest(\ApiVideo\Client\Model\LiveStreamCreationPay ); } + /** * Upload a thumbnail * @@ -537,4 +544,5 @@ private function buildUploadThumbnailRequest(string $liveStreamId, \SplFileObjec ); } + } diff --git a/src/Api/PlayerThemesApi.php b/src/Api/PlayerThemesApi.php index a0d718c..99a7c8e 100644 --- a/src/Api/PlayerThemesApi.php +++ b/src/Api/PlayerThemesApi.php @@ -21,6 +21,7 @@ use ApiVideo\Client\Request; use ApiVideo\Client\ObjectSerializer; use ApiVideo\Client\VideoUploader; +use ApiVideo\Client\ProgressiveUploadSession; /** * @category Class @@ -102,6 +103,7 @@ private function buildDeleteRequest(string $playerId): Request ); } + /** * Delete logo * @@ -163,6 +165,7 @@ private function buildDeleteLogoRequest(string $playerId): Request ); } + /** * List all players * @@ -238,6 +241,7 @@ private function buildListRequest(array $queryParams = []): Request ); } + /** * Show a player * @@ -301,6 +305,7 @@ private function buildGetRequest(string $playerId): Request ); } + /** * Update a player * @@ -375,6 +380,7 @@ private function buildUpdateRequest(string $playerId, \ApiVideo\Client\Model\Pla ); } + /** * Create a player * @@ -433,6 +439,7 @@ private function buildCreateRequest(\ApiVideo\Client\Model\PlayerThemeCreationPa ); } + /** * Upload a logo * @@ -528,4 +535,5 @@ private function buildUploadLogoRequest(string $playerId, \SplFileObject $file, ); } + } diff --git a/src/Api/RawStatisticsApi.php b/src/Api/RawStatisticsApi.php index 117363a..456d62c 100644 --- a/src/Api/RawStatisticsApi.php +++ b/src/Api/RawStatisticsApi.php @@ -21,6 +21,7 @@ use ApiVideo\Client\Request; use ApiVideo\Client\ObjectSerializer; use ApiVideo\Client\VideoUploader; +use ApiVideo\Client\ProgressiveUploadSession; /** * @category Class @@ -126,6 +127,7 @@ private function buildListLiveStreamSessionsRequest(string $liveStreamId, array ); } + /** * List player session events * @@ -205,6 +207,7 @@ private function buildListSessionEventsRequest(string $sessionId, array $queryPa ); } + /** * List video player sessions * @@ -304,4 +307,5 @@ private function buildListVideoSessionsRequest(string $videoId, array $queryPara ); } + } diff --git a/src/Api/UploadTokensApi.php b/src/Api/UploadTokensApi.php index 7a9f194..0c78a11 100644 --- a/src/Api/UploadTokensApi.php +++ b/src/Api/UploadTokensApi.php @@ -21,6 +21,7 @@ use ApiVideo\Client\Request; use ApiVideo\Client\ObjectSerializer; use ApiVideo\Client\VideoUploader; +use ApiVideo\Client\ProgressiveUploadSession; /** * @category Class @@ -102,6 +103,7 @@ private function buildDeleteTokenRequest(string $uploadToken): Request ); } + /** * List all active upload tokens. * @@ -177,6 +179,7 @@ private function buildListRequest(array $queryParams = []): Request ); } + /** * Show upload token * @@ -240,6 +243,7 @@ private function buildGetTokenRequest(string $uploadToken): Request ); } + /** * Generate an upload token * @@ -298,4 +302,5 @@ private function buildCreateTokenRequest(\ApiVideo\Client\Model\TokenCreationPay ); } + } diff --git a/src/Api/VideosApi.php b/src/Api/VideosApi.php index f5e4642..cb80e01 100644 --- a/src/Api/VideosApi.php +++ b/src/Api/VideosApi.php @@ -21,6 +21,7 @@ use ApiVideo\Client\Request; use ApiVideo\Client\ObjectSerializer; use ApiVideo\Client\VideoUploader; +use ApiVideo\Client\ProgressiveUploadSession; /** * @category Class @@ -102,6 +103,7 @@ private function buildDeleteRequest(string $videoId): Request ); } + /** * Show a video * @@ -165,6 +167,7 @@ private function buildGetRequest(string $videoId): Request ); } + /** * Show video status * @@ -228,6 +231,7 @@ private function buildGetStatusRequest(string $videoId): Request ); } + /** * List all videos * @@ -341,6 +345,7 @@ private function buildListRequest(array $queryParams = []): Request ); } + /** * Update a video * @@ -415,6 +420,7 @@ private function buildUpdateRequest(string $videoId, \ApiVideo\Client\Model\Vide ); } + /** * Pick a thumbnail * @@ -489,6 +495,7 @@ private function buildPickThumbnailRequest(string $videoId, \ApiVideo\Client\Mod ); } + /** * Upload with an upload token * @@ -588,6 +595,23 @@ private function buildUploadWithUploadTokenRequest(string $token, \SplFileObject ); } + + public function createUploadWithUploadTokenProgressiveSession(string $token, string $videoId = null) { + $resourcePath = '/upload'; + + $queryParams = []; + + // token query params + if ($token !== null) { + $queryParams['token'] = $token; + } + + $query = \http_build_query($queryParams); + $resourcePath = $resourcePath . ($query ? "?{$query}" : ''); + + return new ProgressiveUploadSession($this->client, $resourcePath, $videoId); + } + /** * Create a video * @@ -646,6 +670,7 @@ private function buildCreateRequest(\ApiVideo\Client\Model\VideoCreationPayload ); } + /** * Upload a video * @@ -745,6 +770,21 @@ private function buildUploadRequest(string $videoId, \SplFileObject $file, strin ); } + + public function createUploadProgressiveSession(string $videoId) { + $resourcePath = '/videos/{videoId}/source'; + // path params + if ($videoId !== null) { + $resourcePath = str_replace( + '{' . 'videoId' . '}', + ObjectSerializer::toPathValue($videoId), + $resourcePath + ); + } + + return new ProgressiveUploadSession($this->client, $resourcePath); + } + /** * Upload a thumbnail * @@ -835,4 +875,5 @@ private function buildUploadThumbnailRequest(string $videoId, \SplFileObject $fi ); } + } diff --git a/src/Api/WebhooksApi.php b/src/Api/WebhooksApi.php index 0efc3e1..a39b930 100644 --- a/src/Api/WebhooksApi.php +++ b/src/Api/WebhooksApi.php @@ -21,6 +21,7 @@ use ApiVideo\Client\Request; use ApiVideo\Client\ObjectSerializer; use ApiVideo\Client\VideoUploader; +use ApiVideo\Client\ProgressiveUploadSession; /** * @category Class @@ -102,6 +103,7 @@ private function buildDeleteRequest(string $webhookId): Request ); } + /** * Show Webhook details * @@ -165,6 +167,7 @@ private function buildGetRequest(string $webhookId): Request ); } + /** * List all webhooks * @@ -234,6 +237,7 @@ private function buildListRequest(array $queryParams = []): Request ); } + /** * Create Webhook * @@ -292,4 +296,5 @@ private function buildCreateRequest(\ApiVideo\Client\Model\WebhooksCreationPaylo ); } + } diff --git a/src/BaseClient.php b/src/BaseClient.php index 321b541..d7d2c92 100644 --- a/src/BaseClient.php +++ b/src/BaseClient.php @@ -92,7 +92,7 @@ public function request(Request $commandRequest): ?array $request = $request->withHeader($name, $value); } - $request = $request->withHeader('User-Agent', 'api.video client (php; v:0.0.7; )'); + $request = $request->withHeader('User-Agent', 'api.video client (php; v:0.0.8; )'); return $this->sendRequest($request); } diff --git a/src/Model/Account.php b/src/Model/Account.php deleted file mode 100644 index 4b0f7d6..0000000 --- a/src/Model/Account.php +++ /dev/null @@ -1,205 +0,0 @@ - '\ApiVideo\Client\Model\AccountQuota', - 'features' => 'string[]', - 'environment' => 'string' - ], - [ - 'quota' => null, - 'features' => null, - 'environment' => null - ], - [ - 'quota' => 'quota', - 'features' => 'features', - 'environment' => 'environment' - ], - [ - 'quota' => 'setQuota', - 'features' => 'setFeatures', - 'environment' => 'setEnvironment' - ], - [ - 'quota' => 'getQuota', - 'features' => 'getFeatures', - 'environment' => 'getEnvironment' - ], - null - ); - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['quota'] = isset($data['quota']) ? new AccountQuota($data['quota']) : null; - $this->container['features'] = $data['features'] ?? null; - $this->container['environment'] = $data['environment'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets quota - * - * @return \ApiVideo\Client\Model\AccountQuota|null - */ - public function getQuota() - { - return $this->container['quota']; - } - - /** - * Sets quota - * - * @param \ApiVideo\Client\Model\AccountQuota|null $quota quota - * - * @return self - */ - public function setQuota($quota) - { - $this->container['quota'] = $quota; - - return $this; - } - - /** - * Gets features - * - * @return string[]|null - */ - public function getFeatures() - { - return $this->container['features']; - } - - /** - * Sets features - * - * @param string[]|null $features Deprecated. What features are enabled for your account. Choices include: app.dynamic_metadata - the ability to dynamically tag videos to better segment and understand your audiences, app.event_log - the ability to create and retrieve a log detailing how your videos were interacted with, player.white_label - the ability to customise your player, stats.player_events - the ability to see statistics about how your player is being used, transcode.mp4_support - the ability to reformat content into mp4 using the H264 codec. - * - * @return self - */ - public function setFeatures($features) - { - $this->container['features'] = $features; - - return $this; - } - - /** - * Gets environment - * - * @return string|null - */ - public function getEnvironment() - { - return $this->container['environment']; - } - - /** - * Sets environment - * - * @param string|null $environment Deprecated. Whether you are using your production or sandbox API key will impact what environment is displayed here, as well as stats and features information. If you use your sandbox key, the environment is \"sandbox.\" If you use your production key, the environment is \"production.\" - * - * @return self - */ - public function setEnvironment($environment) - { - $this->container['environment'] = $environment; - - return $this; - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } -} - - diff --git a/src/Model/AccountQuota.php b/src/Model/AccountQuota.php deleted file mode 100644 index 746310e..0000000 --- a/src/Model/AccountQuota.php +++ /dev/null @@ -1,206 +0,0 @@ - 'float', - 'quotaRemaining' => 'float', - 'quotaTotal' => 'float' - ], - [ - 'quotaUsed' => null, - 'quotaRemaining' => null, - 'quotaTotal' => null - ], - [ - 'quotaUsed' => 'quotaUsed', - 'quotaRemaining' => 'quotaRemaining', - 'quotaTotal' => 'quotaTotal' - ], - [ - 'quotaUsed' => 'setQuotaUsed', - 'quotaRemaining' => 'setQuotaRemaining', - 'quotaTotal' => 'setQuotaTotal' - ], - [ - 'quotaUsed' => 'getQuotaUsed', - 'quotaRemaining' => 'getQuotaRemaining', - 'quotaTotal' => 'getQuotaTotal' - ], - null - ); - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->container['quotaUsed'] = $data['quotaUsed'] ?? null; - $this->container['quotaRemaining'] = $data['quotaRemaining'] ?? null; - $this->container['quotaTotal'] = $data['quotaTotal'] ?? null; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets quotaUsed - * - * @return float|null - */ - public function getQuotaUsed() - { - return $this->container['quotaUsed']; - } - - /** - * Sets quotaUsed - * - * @param float|null $quotaUsed Deprecated - * - * @return self - */ - public function setQuotaUsed($quotaUsed) - { - $this->container['quotaUsed'] = $quotaUsed; - - return $this; - } - - /** - * Gets quotaRemaining - * - * @return float|null - */ - public function getQuotaRemaining() - { - return $this->container['quotaRemaining']; - } - - /** - * Sets quotaRemaining - * - * @param float|null $quotaRemaining Deprecated - * - * @return self - */ - public function setQuotaRemaining($quotaRemaining) - { - $this->container['quotaRemaining'] = $quotaRemaining; - - return $this; - } - - /** - * Gets quotaTotal - * - * @return float|null - */ - public function getQuotaTotal() - { - return $this->container['quotaTotal']; - } - - /** - * Sets quotaTotal - * - * @param float|null $quotaTotal Deprecated - * - * @return self - */ - public function setQuotaTotal($quotaTotal) - { - $this->container['quotaTotal'] = $quotaTotal; - - return $this; - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } -} - - diff --git a/src/Model/TokenCreationPayload.php b/src/Model/TokenCreationPayload.php index 84dddf1..1b7be82 100644 --- a/src/Model/TokenCreationPayload.php +++ b/src/Model/TokenCreationPayload.php @@ -113,7 +113,7 @@ public function getTtl() /** * Sets ttl * - * @param int|null $ttl Time in seconds that the token will be active. A value of 0 means that the token has no expiration date. The default is to have no expiration. + * @param int|null $ttl Time in seconds that the token will be active. A value of 0 means that the token has no exipration date. The default is to have no expiration. * * @return self */ diff --git a/src/Model/Video.php b/src/Model/Video.php index 08affe3..47547ce 100644 --- a/src/Model/Video.php +++ b/src/Model/Video.php @@ -213,7 +213,7 @@ public function getCreatedAt() /** * Sets createdAt * - * @param \DateTime|null $createdAt When an webhook was created, presented in ISO-8601 format. + * @param \DateTime|null $createdAt When a video was created, presented in ISO-8601 format. * * @return self */ @@ -357,7 +357,7 @@ public function getMetadata() /** * Sets metadata * - * @param \ApiVideo\Client\Model\Metadata[]|null $metadata Metadata you can use to categorise and filter videos. Metadata is a list of dictionaries, where each dictionary represents a key value pair for categorising a video. + * @param \ApiVideo\Client\Model\Metadata[]|null $metadata Metadata you can use to categorise and filter videos. Metadata is a list of dictionaries, where each dictionary represents a key value pair for categorising a video. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair. * * @return self */ @@ -453,7 +453,7 @@ public function getPublic() /** * Sets public * - * @param bool|null $public Defines if the content is publicly reachable or if a unique token is needed for each play session. + * @param bool|null $public Defines if the content is publicly reachable or if a unique token is needed for each play session. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos). * * @return self */ diff --git a/src/Model/VideoCreationPayload.php b/src/Model/VideoCreationPayload.php index 7634175..c44bb3b 100644 --- a/src/Model/VideoCreationPayload.php +++ b/src/Model/VideoCreationPayload.php @@ -228,7 +228,7 @@ public function getPublic() /** * Sets public * - * @param bool|null $public Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view. + * @param bool|null $public Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos). * * @return self */ @@ -348,7 +348,7 @@ public function getMetadata() /** * Sets metadata * - * @param \ApiVideo\Client\Model\Metadata[]|null $metadata A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. You can also just use the pairs as another way to tag and categorize your videos. + * @param \ApiVideo\Client\Model\Metadata[]|null $metadata A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. Read more on [dynamic metadata](https://api.video/blog/endpoints/dynamic-metadata). * * @return self */ diff --git a/src/Model/VideoThumbnailPickPayload.php b/src/Model/VideoThumbnailPickPayload.php index a268693..d3481b7 100644 --- a/src/Model/VideoThumbnailPickPayload.php +++ b/src/Model/VideoThumbnailPickPayload.php @@ -112,7 +112,7 @@ public function getTimecode() /** * Sets timecode * - * @param string $timecode Frame in video to be used as a placeholder before the video plays. Example: '\"00:01:00.000\" for 1 minute into the video.' Valid Patterns: \"hh:mm:ss.ms\" \"hh:mm:ss:frameNumber\" \"124\" (integer value is reported as seconds) If selection is out of range, \"00:00:00.00\" will be chosen. + * @param string $timecode Frame in video to be used as a placeholder before the video plays. Example: '\"00:01:00.000\" for 1 minute into the video.' Valid Patterns: \"hh:mm:ss.ms\" \"hh:mm:ss:frameNumber\" \"124\" (integer value is reported as seconds) If selection is out of range, \"00:00:00.00\" will be chosen. * * @return self */ diff --git a/src/Model/VideoUpdatePayload.php b/src/Model/VideoUpdatePayload.php index dabcafa..e6c527b 100644 --- a/src/Model/VideoUpdatePayload.php +++ b/src/Model/VideoUpdatePayload.php @@ -219,7 +219,7 @@ public function getPublic() /** * Sets public * - * @param bool|null $public Whether the video is publicly available or not. False means it is set to private. + * @param bool|null $public Whether the video is publicly available or not. False means it is set to private. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos). * * @return self */ @@ -315,7 +315,7 @@ public function getMetadata() /** * Sets metadata * - * @param \ApiVideo\Client\Model\Metadata[]|null $metadata A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. + * @param \ApiVideo\Client\Model\Metadata[]|null $metadata A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair. * * @return self */ diff --git a/src/ProgressiveUploadSession.php b/src/ProgressiveUploadSession.php new file mode 100644 index 0000000..8121019 --- /dev/null +++ b/src/ProgressiveUploadSession.php @@ -0,0 +1,103 @@ +client = $client; + $this->endpoint = $endpoint; + $this->currentPart = 1; + $this->videoId = $videoId; + } + + /** + * @param SplFileObject $file + * @param bool $isLastPart + * @return Video + */ + public function uploadPart(SplFileObject $file, $isLastPart = false): Video + { + return $this->execute( + $this->endpoint, + $file, + $isLastPart + ); + } + + /** + * @param SplFileObject $file + * @return Video + */ + public function uploadLastPart(SplFileObject $file): Video + { + return $this->uploadPart( + $file, + true + ); + } + + /** + * @param string $path + * @param SplFileObject $file + * @param bool $isLast + * @return Video + */ + private function execute(string $path, \SplFileObject $file, bool $isLast): Video + { + $fileSize = filesize($file->getRealPath()); + $handle = fopen($file->getRealPath(), 'r'); + $response = null; + + $builder = new MultipartStreamBuilder($this->client->getStreamFactory()); + $builder->addResource('file', $handle, [ + 'filename' => basename($file->getRealPath()), + 'headers' => ['Content-Type' => 'application/octet-stream'], + ]); + + if ($this->videoId) { + $builder->addResource('videoId', $this->videoId); + } + + $request = new Request( + 'POST', + $path, + [ + 'Accept' => 'application/json', + 'Content-Type' => sprintf('multipart/form-data; boundary="%s"', $builder->getBoundary()), + 'Content-Range' => sprintf('part %s/%s', $this->currentPart, $isLast ? $this->currentPart : "*"), + ] + ); + $request->setStream($builder->build()); + + $response = $this->client->request($request); + + $this->videoId = $response['videoId'] ?? null; + + $this->currentPart++; + + fclose($handle); + + return new Video($response); + } + +} diff --git a/src/VideoUploader.php b/src/VideoUploader.php index 34e8b6a..3b63bce 100644 --- a/src/VideoUploader.php +++ b/src/VideoUploader.php @@ -73,6 +73,9 @@ private function execute(string $path, \SplFileObject $file, int $chunkSize): Vi $response = null; $videoId = null; + $part = 1; + $partsCount = ceil($fileSize / $chunkSize); + while ($start < $fileSize) { $contents = fread($handle, $chunkSize); @@ -92,7 +95,7 @@ private function execute(string $path, \SplFileObject $file, int $chunkSize): Vi [ 'Accept' => 'application/json', 'Content-Type' => sprintf('multipart/form-data; boundary="%s"', $builder->getBoundary()), - 'Content-Range' => sprintf('bytes %s-%s/%s', $start, $start + strlen($contents) - 1, $fileSize), + 'Content-Range' => sprintf('part %s/%s', $part, $partsCount), ] ); $request->setStream($builder->build()); @@ -103,6 +106,7 @@ private function execute(string $path, \SplFileObject $file, int $chunkSize): Vi $start += strlen($contents); fseek($handle, $start); + $part++; } fclose($handle); diff --git a/tests/Api/VideosApiTest.php b/tests/Api/VideosApiTest.php index 19bf716..fc43ad0 100644 --- a/tests/Api/VideosApiTest.php +++ b/tests/Api/VideosApiTest.php @@ -3,6 +3,7 @@ namespace ApiVideo\Client\Tests\Api; use ApiVideo\Client\Client; +use ApiVideo\Client\Model\TokenCreationPayload; use ApiVideo\Client\Model\VideoCreationPayload; use ApiVideo\Client\Model\VideosListResponse; use ApiVideo\Client\Model\VideoThumbnailPickPayload; @@ -70,6 +71,56 @@ public function testUpload() $this->assertContains($videoStatus->getIngest()->getStatus(), ['uploaded', 'uploading']); } + public function testProgressiveUpload() { + $part1 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.a'); + $part2 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.b'); + $part3 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.c'); + + $createdVideo = $this->client->videos()->create((new VideoCreationPayload())->setTitle('Progressive upload')); + + $session = $this->client->videos()->createUploadProgressiveSession($createdVideo->getVideoId()); + + $session->uploadPart($part1); + $session->uploadPart( $part2); + $video = $session->uploadLastPart($part3); + + $this->assertEquals('Progressive upload', $video->getTitle()); + } + + public function testProgressiveUploadWithUploadToken() { + $part1 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.a'); + $part2 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.b'); + $part3 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.c'); + + $uploadToken = $this->client->uploadTokens()->createToken(new TokenCreationPayload())->getToken(); + + $session = $this->client->videos()->createUploadWithUploadTokenProgressiveSession($uploadToken); + + $session->uploadPart($part1); + $session->uploadPart( $part2); + $video = $session->uploadLastPart($part3); + + $this->assertEquals('10m.mp4.part.a', $video->getTitle()); + } + + public function testProgressiveUploadWithUploadTokenExistingVideo() { + $part1 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.a'); + $part2 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.b'); + $part3 = new SplFileObject(__DIR__ . '/../resources/10m.mp4.part.c'); + + $createdVideo = $this->client->videos()->create((new VideoCreationPayload())->setTitle('Progressive upload using upload token')); + $uploadToken = $this->client->uploadTokens()->createToken(new TokenCreationPayload())->getToken(); + + print_r($uploadToken); + $session = $this->client->videos()->createUploadWithUploadTokenProgressiveSession($uploadToken, $createdVideo->getVideoId()); + + $session->uploadPart($part1); + $session->uploadPart( $part2); + $video = $session->uploadLastPart($part3); + + $this->assertEquals('Progressive upload using upload token', $video->getTitle()); + } + public function testTags() { $this->client->videos()->create((new VideoCreationPayload()) ->setTitle('Video A')); diff --git a/tests/resources/10m.mp4.part.a b/tests/resources/10m.mp4.part.a new file mode 100644 index 0000000..3a307f4 Binary files /dev/null and b/tests/resources/10m.mp4.part.a differ diff --git a/tests/resources/10m.mp4.part.b b/tests/resources/10m.mp4.part.b new file mode 100644 index 0000000..adc7d29 Binary files /dev/null and b/tests/resources/10m.mp4.part.b differ diff --git a/tests/resources/10m.mp4.part.c b/tests/resources/10m.mp4.part.c new file mode 100644 index 0000000..1b4526b Binary files /dev/null and b/tests/resources/10m.mp4.part.c differ