diff --git a/CHANGELOG.md b/CHANGELOG.md index 69fef0c..8ce5875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All changes to this project will be documented in this file. +## [1.4.3] - 2024-09-30 +- Add /tags API endpoint + ## [1.4.2] - 2024-09-16 - Add discarded video endpoints diff --git a/README.md b/README.md index a06f173..3e1248b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ - [ChaptersApi](#chaptersapi) - [LiveStreamsApi](#livestreamsapi) - [PlayerThemesApi](#playerthemesapi) + - [TagsApi](#tagsapi) - [UploadTokensApi](#uploadtokensapi) - [VideosApi](#videosapi) - [WatermarksApi](#watermarksapi) @@ -185,6 +186,13 @@ Method | Description | HTTP request [**deleteLogo()**](https://github.com/apivideo/api.video-php-client/blob/main/docs/Api/PlayerThemesApi.md#deleteLogo) | Delete logo | **DELETE** `/players/{playerId}/logo` +#### TagsApi + +Method | Description | HTTP request +------------- | ------------- | ------------- +[**list()**](https://github.com/apivideo/api.video-php-client/blob/main/docs/Api/TagsApi.md#list) | List all video tags | **GET** `/tags` + + #### UploadTokensApi Method | Description | HTTP request @@ -263,6 +271,8 @@ Method | Description | HTTP request - [FilterBy1](https://github.com/apivideo/api.video-php-client/blob/main/docs/Model/FilterBy1.md) - [FilterBy2](https://github.com/apivideo/api.video-php-client/blob/main/docs/Model/FilterBy2.md) - [Link](https://github.com/apivideo/api.video-php-client/blob/main/docs/Model/Link.md) + - [ListTagsResponse](https://github.com/apivideo/api.video-php-client/blob/main/docs/Model/ListTagsResponse.md) + - [ListTagsResponseData](https://github.com/apivideo/api.video-php-client/blob/main/docs/Model/ListTagsResponseData.md) - [LiveStream](https://github.com/apivideo/api.video-php-client/blob/main/docs/Model/LiveStream.md) - [LiveStreamAssets](https://github.com/apivideo/api.video-php-client/blob/main/docs/Model/LiveStreamAssets.md) - [LiveStreamCreationPayload](https://github.com/apivideo/api.video-php-client/blob/main/docs/Model/LiveStreamCreationPayload.md) diff --git a/docs/Api/TagsApi.md b/docs/Api/TagsApi.md new file mode 100644 index 0000000..c34a8c1 --- /dev/null +++ b/docs/Api/TagsApi.md @@ -0,0 +1,37 @@ +# ApiVideo\Client\Api\TagsApi + +All URIs are relative to https://ws.api.video. + +Method | Description | HTTP request +------------- | ------------- | ------------- +[**list()**](TagsApi.md#list) | List all video tags | **GET** /tags + + +## **`list()` - List all video tags** + + + +This endpoint enables you to search for video tags in a project and see how many videos are tagged with them. If you do not define any query parameters, the endpoint lists all video tags and the numbers of times they are used in a project. + +### Arguments + + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + `value` | **string**| Use this parameter to search for specific video tags. The API filters results even on partial values, and ignores accents, uppercase, and lowercase. | [optional] + `sortBy` | **string**| Use this parameter to choose which field the API will use to sort the response data. The default is `value`. These are the available fields to sort by: - `value`: Sorts the results based on tag values in alphabetic order. - `videoCount`: Sorts the results based on the number of times a video tag is used. | [optional] + `sortOrder` | **string**| Use this parameter to sort results. `asc` is ascending and sorts from A to Z. `desc` is descending and sorts from Z to A. | [optional] + `currentPage` | **int**| Choose the number of search results to return per page. Minimum value: 1 | [optional] [default to 1] + `pageSize` | **int**| Results per page. Allowed values 1-100, default is 25. | [optional] [default to 25] + + + + +### Return type + +[**\ApiVideo\Client\Model\ListTagsResponse**](../Model/ListTagsResponse.md) + + + + diff --git a/docs/Model/ListTagsResponse.md b/docs/Model/ListTagsResponse.md new file mode 100644 index 0000000..166a4ce --- /dev/null +++ b/docs/Model/ListTagsResponse.md @@ -0,0 +1,10 @@ +# # ListTagsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | [**\ApiVideo\Client\Model\ListTagsResponseData[]**](ListTagsResponseData.md) | | [optional] +**pagination** | [**\ApiVideo\Client\Model\Pagination**](Pagination.md) | | [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/ListTagsResponseData.md b/docs/Model/ListTagsResponseData.md new file mode 100644 index 0000000..4773102 --- /dev/null +++ b/docs/Model/ListTagsResponseData.md @@ -0,0 +1,10 @@ +# # ListTagsResponseData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **string** | Returns the value of a video tag used in your project. | [optional] +**videoCount** | **int** | Returns the number of times a video tag is used. | [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/TagsApi.php b/src/Api/TagsApi.php new file mode 100644 index 0000000..a1ebc98 --- /dev/null +++ b/src/Api/TagsApi.php @@ -0,0 +1,118 @@ +client = $client; + } + + /** + * List all video tags + * + * + * @throws \ApiVideo\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \ApiVideo\Client\Model\ListTagsResponse|\ApiVideo\Client\Model\TooManyRequests + */ + public function list(string $value = null, string $sortBy = null, string $sortOrder = null, int $currentPage = 1, int $pageSize = 25): \ApiVideo\Client\Model\ListTagsResponse + { + $request = $this->buildListRequest(); + + $model = new \ApiVideo\Client\Model\ListTagsResponse($this->client->request($request)); + + return $model; + } + + /** + * Create request for operation 'list' + * + * + * @throws \InvalidArgumentException + * @return Request + */ + private function buildListRequest(string $value = null, string $sortBy = null, string $sortOrder = null, int $currentPage = 1, int $pageSize = 25): Request + { + + $resourcePath = '/tags'; + $formParams = []; + $queryParams = []; + $headers = []; + $httpBody = ''; + $multipart = false; + + // value query params + if ($value !== null) { + $queryParams['value'] = $value; + } + + // sortBy query params + if ($sortBy !== null) { + $queryParams['sortBy'] = $sortBy; + } + + // sortOrder query params + if ($sortOrder !== null) { + $queryParams['sortOrder'] = $sortOrder; + } + + // currentPage query params + if ($currentPage !== null) { + $queryParams['currentPage'] = $currentPage; + } + + // pageSize query params + if ($pageSize !== null) { + $queryParams['pageSize'] = $pageSize; + } + + + + + $query = \http_build_query($queryParams); + + return new Request( + 'GET', + $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + +} diff --git a/src/BaseClient.php b/src/BaseClient.php index c3a7384..273dbc3 100644 --- a/src/BaseClient.php +++ b/src/BaseClient.php @@ -78,7 +78,7 @@ public function __construct(string $baseUri, ?string $apiKey, ClientInterface $h $this->originSdkHeaderValue = ""; if ($apiKey) { - $this->authenticator = new Authenticator($this, $apiKey, 'php:1.4.2'); + $this->authenticator = new Authenticator($this, $apiKey, 'php:1.4.3'); } } @@ -111,7 +111,7 @@ public function request(Request $commandRequest, bool $skipAuthRequest = false): if($this->originSdkHeaderValue) { $request = $request->withHeader('AV-Origin-Sdk', $this->originSdkHeaderValue); } - $request = $request->withHeader('AV-Origin-Client', 'php:1.4.2'); + $request = $request->withHeader('AV-Origin-Client', 'php:1.4.3'); return $this->sendRequest($request, $skipAuthRequest); } diff --git a/src/Client.php b/src/Client.php index ed9196c..700a6c1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -132,6 +132,18 @@ public function playerThemes(): \ApiVideo\Client\Api\PlayerThemesApi return $this->services['playerThemes']; } + /** + * @return \ApiVideo\Client\Api\TagsApi + */ + public function tags(): \ApiVideo\Client\Api\TagsApi + { + if (!array_key_exists('tags', $this->services)) { + $this->services['tags'] = new \ApiVideo\Client\Api\TagsApi($this->baseClient); + } + + return $this->services['tags']; + } + /** * @return \ApiVideo\Client\Api\UploadTokensApi */ diff --git a/src/Model/ListTagsResponse.php b/src/Model/ListTagsResponse.php new file mode 100644 index 0000000..13f95c1 --- /dev/null +++ b/src/Model/ListTagsResponse.php @@ -0,0 +1,180 @@ + '\ApiVideo\Client\Model\ListTagsResponseData[]', + 'pagination' => '\ApiVideo\Client\Model\Pagination' + ], + [ + 'data' => null, + 'pagination' => null + ], + [ + 'data' => 'data', + 'pagination' => 'pagination' + ], + [ + 'data' => 'setData', + 'pagination' => 'setPagination' + ], + [ + 'data' => 'getData', + 'pagination' => 'getPagination' + ], + [ + 'data' => null, + 'pagination' => null + ], + 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['data'] = isset($data['data']) ? array_map(function(array $value): ListTagsResponseData { return new ListTagsResponseData($value); }, $data['data']) : null; + $this->container['pagination'] = isset($data['pagination']) ? new Pagination($data['pagination']) : 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 data + * + * @return \ApiVideo\Client\Model\ListTagsResponseData[]|null + */ + public function getData() + { + return $this->container['data']; + } + + /** + * Sets data + * + * @param \ApiVideo\Client\Model\ListTagsResponseData[]|null $data data + * + * @return self + */ + public function setData($data) + { + $this->container['data'] = $data; + + return $this; + } + + /** + * Gets pagination + * + * @return \ApiVideo\Client\Model\Pagination|null + */ + public function getPagination() + { + return $this->container['pagination']; + } + + /** + * Sets pagination + * + * @param \ApiVideo\Client\Model\Pagination|null $pagination pagination + * + * @return self + */ + public function setPagination($pagination) + { + $this->container['pagination'] = $pagination; + + 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. + */ + #[\ReturnTypeWillChange] + 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/ListTagsResponseData.php b/src/Model/ListTagsResponseData.php new file mode 100644 index 0000000..8421668 --- /dev/null +++ b/src/Model/ListTagsResponseData.php @@ -0,0 +1,180 @@ + 'string', + 'videoCount' => 'int' + ], + [ + 'value' => null, + 'videoCount' => null + ], + [ + 'value' => 'value', + 'videoCount' => 'videoCount' + ], + [ + 'value' => 'setValue', + 'videoCount' => 'setVideoCount' + ], + [ + 'value' => 'getValue', + 'videoCount' => 'getVideoCount' + ], + [ + 'value' => null, + 'videoCount' => null + ], + 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['value'] = $data['value'] ?? null; + $this->container['videoCount'] = $data['videoCount'] ?? 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 value + * + * @return string|null + */ + public function getValue() + { + return $this->container['value']; + } + + /** + * Sets value + * + * @param string|null $value Returns the value of a video tag used in your project. + * + * @return self + */ + public function setValue($value) + { + $this->container['value'] = $value; + + return $this; + } + + /** + * Gets videoCount + * + * @return int|null + */ + public function getVideoCount() + { + return $this->container['videoCount']; + } + + /** + * Sets videoCount + * + * @param int|null $videoCount Returns the number of times a video tag is used. + * + * @return self + */ + public function setVideoCount($videoCount) + { + $this->container['videoCount'] = $videoCount; + + 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. + */ + #[\ReturnTypeWillChange] + 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 + ); + } +} + +