From 199c172d54bc6d348250f828bf245f504336a432 Mon Sep 17 00:00:00 2001 From: olivierapivideo Date: Wed, 2 Oct 2024 12:57:45 +0000 Subject: [PATCH] Add video tags endpoint --- CHANGELOG.md | 3 + README.md | 10 ++ docs/Api/TagsApi.md | 43 +++++++ docs/Model/ListTagsResponse.md | 10 ++ docs/Model/ListTagsResponseData.md | 10 ++ docs/Model/Webhook.md | 9 +- src/Api/TagsApi.php | 127 ++++++++++++++++++++ src/BaseClient.php | 4 +- src/Client.php | 12 ++ src/Model/ListTagsResponse.php | 180 +++++++++++++++++++++++++++++ src/Model/ListTagsResponseData.php | 180 +++++++++++++++++++++++++++++ src/Model/Webhook.php | 51 ++++++-- 12 files changed, 623 insertions(+), 16 deletions(-) create mode 100644 docs/Api/TagsApi.md create mode 100644 docs/Model/ListTagsResponse.md create mode 100644 docs/Model/ListTagsResponseData.md create mode 100644 src/Api/TagsApi.php create mode 100644 src/Model/ListTagsResponse.php create mode 100644 src/Model/ListTagsResponseData.php 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..8c91010 --- /dev/null +++ b/docs/Api/TagsApi.md @@ -0,0 +1,43 @@ +# 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 + + + + + +Note: `queryParams` argument is an associative array with the keys listed below. + +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/docs/Model/Webhook.md b/docs/Model/Webhook.md index 2f240e6..63bbb58 100644 --- a/docs/Model/Webhook.md +++ b/docs/Model/Webhook.md @@ -4,9 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**webhookId** | **string** | Unique identifier of the webhook | [optional] -**createdAt** | [**\DateTime**](\DateTime.md) | When an webhook was created, presented in ATOM UTC format. | [optional] -**events** | **string[]** | A list of events that will trigger the webhook. | [optional] -**url** | **string** | URL of the webhook | [optional] +**webhookId** | **string** | A unique identifier of the webhook you subscribed to. | [optional] +**createdAt** | [**\DateTime**](\DateTime.md) | The time and date when you created this webhook subscription, in ATOM UTC format. | [optional] +**events** | **string[]** | A list of events that you subscribed to. When these events occur, the API triggers a webhook call to the URL you provided. | [optional] +**url** | **string** | The URL where the API sends the webhook. | [optional] +**signatureSecret** | **string** | A secret key for the webhook you subscribed to. You can use it to verify the origin of the webhook call that you receive. | [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..5635ac3 --- /dev/null +++ b/src/Api/TagsApi.php @@ -0,0 +1,127 @@ +client = $client; + } + + /** + * List all video tags + * + * @param array $queryParams + * + * @throws \ApiVideo\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \ApiVideo\Client\Model\ListTagsResponse|\ApiVideo\Client\Model\TooManyRequests + */ + public function list(array $queryParams = []): \ApiVideo\Client\Model\ListTagsResponse + { + $request = $this->buildListRequest($queryParams); + + $model = new \ApiVideo\Client\Model\ListTagsResponse($this->client->request($request)); + + return $model; + } + + /** + * Create request for operation 'list' + * + * @param array $queryParams + * + * @throws \InvalidArgumentException + * @return Request + */ + private function buildListRequest(array $queryParams = []): Request + { + // unbox the parameters from the associative array + $value = array_key_exists('value', $queryParams) ? $queryParams['value'] : null; + $sortBy = array_key_exists('sortBy', $queryParams) ? $queryParams['sortBy'] : null; + $sortOrder = array_key_exists('sortOrder', $queryParams) ? $queryParams['sortOrder'] : null; + $currentPage = array_key_exists('currentPage', $queryParams) ? $queryParams['currentPage'] : 1; + $pageSize = array_key_exists('pageSize', $queryParams) ? $queryParams['pageSize'] : 25; + + + $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 + ); + } +} + + diff --git a/src/Model/Webhook.php b/src/Model/Webhook.php index 508d5f7..34b944a 100644 --- a/src/Model/Webhook.php +++ b/src/Model/Webhook.php @@ -34,37 +34,43 @@ public static function getDefinition(): ModelDefinition 'webhookId' => 'string', 'createdAt' => '\DateTime', 'events' => 'string[]', - 'url' => 'string' + 'url' => 'string', + 'signatureSecret' => 'string' ], [ 'webhookId' => null, 'createdAt' => 'date-time', 'events' => null, - 'url' => null + 'url' => null, + 'signatureSecret' => null ], [ 'webhookId' => 'webhookId', 'createdAt' => 'createdAt', 'events' => 'events', - 'url' => 'url' + 'url' => 'url', + 'signatureSecret' => 'signatureSecret' ], [ 'webhookId' => 'setWebhookId', 'createdAt' => 'setCreatedAt', 'events' => 'setEvents', - 'url' => 'setUrl' + 'url' => 'setUrl', + 'signatureSecret' => 'setSignatureSecret' ], [ 'webhookId' => 'getWebhookId', 'createdAt' => 'getCreatedAt', 'events' => 'getEvents', - 'url' => 'getUrl' + 'url' => 'getUrl', + 'signatureSecret' => 'getSignatureSecret' ], [ 'webhookId' => null, 'createdAt' => null, 'events' => null, - 'url' => null + 'url' => null, + 'signatureSecret' => null ], null ); @@ -90,6 +96,7 @@ public function __construct(array $data = null) $this->container['createdAt'] = isset($data['createdAt']) ? new \DateTime($data['createdAt']) : null; $this->container['events'] = $data['events'] ?? null; $this->container['url'] = $data['url'] ?? null; + $this->container['signatureSecret'] = $data['signatureSecret'] ?? null; } /** @@ -129,7 +136,7 @@ public function getWebhookId() /** * Sets webhookId * - * @param string|null $webhookId Unique identifier of the webhook + * @param string|null $webhookId A unique identifier of the webhook you subscribed to. * * @return self */ @@ -153,7 +160,7 @@ public function getCreatedAt() /** * Sets createdAt * - * @param \DateTime|null $createdAt When an webhook was created, presented in ATOM UTC format. + * @param \DateTime|null $createdAt The time and date when you created this webhook subscription, in ATOM UTC format. * * @return self */ @@ -177,7 +184,7 @@ public function getEvents() /** * Sets events * - * @param string[]|null $events A list of events that will trigger the webhook. + * @param string[]|null $events A list of events that you subscribed to. When these events occur, the API triggers a webhook call to the URL you provided. * * @return self */ @@ -201,7 +208,7 @@ public function getUrl() /** * Sets url * - * @param string|null $url URL of the webhook + * @param string|null $url The URL where the API sends the webhook. * * @return self */ @@ -212,6 +219,30 @@ public function setUrl($url) return $this; } + /** + * Gets signatureSecret + * + * @return string|null + */ + public function getSignatureSecret() + { + return $this->container['signatureSecret']; + } + + /** + * Sets signatureSecret + * + * @param string|null $signatureSecret A secret key for the webhook you subscribed to. You can use it to verify the origin of the webhook call that you receive. + * + * @return self + */ + public function setSignatureSecret($signatureSecret) + { + $this->container['signatureSecret'] = $signatureSecret; + + 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