diff --git a/CHANGELOG.md b/CHANGELOG.md index 0875cd3..0f56080 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.1] - 2024-09-05 +- Add sort parameters in analytics endpoints + ## [1.4.0] - 2024-07-29 - Add new analytics methods - Add livestream complete() method diff --git a/api/openapi.yaml b/api/openapi.yaml index c81c326..46e45aa 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -11682,6 +11682,42 @@ paths: format: date-time type: string style: form + - description: | + Use this parameter to choose which field the API will use to sort the analytics data. + + These are the available fields to sort by: + + - `metricValue`: Sorts the results based on the **metric** you selected in your request. + - `dimensionValue`: Sorts the results based on the **dimension** you selected in your request. + example: metricValue + explode: false + in: query + name: sortBy + required: false + schema: + enum: + - metricValue + - dimensionValue + type: string + style: form + - description: | + Use this parameter to define the sort order of results. + + These are the available sort orders: + + - `asc`: Sorts the results in ascending order: `A to Z` and `0 to 9`. + - `desc`: Sorts the results in descending order: `Z to A` and `9 to 0`. + example: asc + explode: false + in: query + name: sortOrder + required: false + schema: + enum: + - asc + - desc + type: string + style: form - $ref: '#/components/parameters/filterBy_2' description: "Use this parameter to filter the API's response based on different\ \ data dimensions. You can serialize filters in your query to receive more\ @@ -12124,6 +12160,42 @@ paths: - day type: string style: form + - description: | + Use this parameter to choose which field the API will use to sort the analytics data. + + These are the available fields to sort by: + + - `metricValue`: Sorts the results based on the **metric** you selected in your request. + - `emittedAt`: Sorts the results based on the **timestamp** of the event in ATOM date-time format. + example: metricValue + explode: false + in: query + name: sortBy + required: false + schema: + enum: + - metricValue + - emittedAt + type: string + style: form + - description: | + Use this parameter to define the sort order of results. + + These are the available sort orders: + + - `asc`: Sorts the results in ascending order: `A to Z` and `0 to 9`. + - `desc`: Sorts the results in descending order: `Z to A` and `9 to 0`. + example: asc + explode: false + in: query + name: sortOrder + required: false + schema: + enum: + - asc + - desc + type: string + style: form - $ref: '#/components/parameters/filterBy_2' description: "Use this parameter to filter the API's response based on different\ \ data dimensions. You can serialize filters in your query to receive more\ diff --git a/api_analytics.go b/api_analytics.go index cbdf333..43d1141 100644 --- a/api_analytics.go +++ b/api_analytics.go @@ -45,6 +45,8 @@ func (r AnalyticsApiGetAggregatedMetricsRequest) FilterBy(filterBy FilterBy2) An type AnalyticsApiGetMetricsBreakdownRequest struct { from *time.Time to *time.Time + sortBy *string + sortOrder *string filterBy *FilterBy2 currentPage *int32 pageSize *int32 @@ -58,6 +60,14 @@ func (r AnalyticsApiGetMetricsBreakdownRequest) To(to time.Time) AnalyticsApiGet r.to = &to return r } +func (r AnalyticsApiGetMetricsBreakdownRequest) SortBy(sortBy string) AnalyticsApiGetMetricsBreakdownRequest { + r.sortBy = &sortBy + return r +} +func (r AnalyticsApiGetMetricsBreakdownRequest) SortOrder(sortOrder string) AnalyticsApiGetMetricsBreakdownRequest { + r.sortOrder = &sortOrder + return r +} func (r AnalyticsApiGetMetricsBreakdownRequest) FilterBy(filterBy FilterBy2) AnalyticsApiGetMetricsBreakdownRequest { r.filterBy = &filterBy return r @@ -75,6 +85,8 @@ type AnalyticsApiGetMetricsOverTimeRequest struct { from *time.Time to *time.Time interval *string + sortBy *string + sortOrder *string filterBy *FilterBy2 currentPage *int32 pageSize *int32 @@ -92,6 +104,14 @@ func (r AnalyticsApiGetMetricsOverTimeRequest) Interval(interval string) Analyti r.interval = &interval return r } +func (r AnalyticsApiGetMetricsOverTimeRequest) SortBy(sortBy string) AnalyticsApiGetMetricsOverTimeRequest { + r.sortBy = &sortBy + return r +} +func (r AnalyticsApiGetMetricsOverTimeRequest) SortOrder(sortOrder string) AnalyticsApiGetMetricsOverTimeRequest { + r.sortOrder = &sortOrder + return r +} func (r AnalyticsApiGetMetricsOverTimeRequest) FilterBy(filterBy FilterBy2) AnalyticsApiGetMetricsOverTimeRequest { r.filterBy = &filterBy return r @@ -268,6 +288,12 @@ func (s *AnalyticsService) GetMetricsBreakdownWithContext(ctx context.Context, m if r.to != nil { localVarQueryParams.Add("to", parameterToString(*r.to, "")) } + if r.sortBy != nil { + localVarQueryParams.Add("sortBy", parameterToString(*r.sortBy, "")) + } + if r.sortOrder != nil { + localVarQueryParams.Add("sortOrder", parameterToString(*r.sortOrder, "")) + } if r.filterBy != nil { addDeepQueryParams(r.filterBy, "filterBy", localVarQueryParams) } @@ -334,6 +360,12 @@ func (s *AnalyticsService) GetMetricsOverTimeWithContext(ctx context.Context, me if r.interval != nil { localVarQueryParams.Add("interval", parameterToString(*r.interval, "")) } + if r.sortBy != nil { + localVarQueryParams.Add("sortBy", parameterToString(*r.sortBy, "")) + } + if r.sortOrder != nil { + localVarQueryParams.Add("sortOrder", parameterToString(*r.sortOrder, "")) + } if r.filterBy != nil { addDeepQueryParams(r.filterBy, "filterBy", localVarQueryParams) } diff --git a/client.go b/client.go index 0a4f538..b96f1be 100644 --- a/client.go +++ b/client.go @@ -255,7 +255,7 @@ func (c *Client) prepareRequest( req.Header.Set("AV-Origin-Sdk", originSdkHeaderValue) } - req.Header.Set("AV-Origin-Client", "go:1.4.0") + req.Header.Set("AV-Origin-Client", "go:1.4.1") for headerName := range headerParams { req.Header.Set(headerName, headerParams[headerName]) @@ -530,7 +530,7 @@ func (c *Client) auth(req *http.Request) (*http.Request, error) { req.Header.Set("AV-Origin-Sdk", originSdkHeaderValue) } - req.Header.Set("AV-Origin-Client", "go:1.4.0") + req.Header.Set("AV-Origin-Client", "go:1.4.1") resp, err := c.httpClient.Do(req) diff --git a/docs/Analytics.md b/docs/Analytics.md index 8feb233..185241d 100644 --- a/docs/Analytics.md +++ b/docs/Analytics.md @@ -121,6 +121,8 @@ func main() { req.Breakdown("breakdown_example") // string | Use this path parameter to define a dimension for segmenting analytics data. You must use `kebab-case` for path parameters. These are the available dimensions: - `media-id`: Returns analytics based on the unique identifiers of a video or a live stream. - `media-type`: Returns analytics based on the type of content. Possible values: `video` and `live-stream`. - `continent`: Returns analytics based on the viewers' continent. The list of supported continents names are based on the [GeoNames public database](https://www.geonames.org/countries/). Possible values are: `AS`, `AF`, `NA`, `SA`, `AN`, `EU`, `AZ`. - `country`: Returns analytics based on the viewers' country. The list of supported country names are based on the [GeoNames public database](https://www.geonames.org/countries/). - `device-type`: Returns analytics based on the type of device used by the viewers. Response values can include: `computer`, `phone`, `tablet`, `tv`, `console`, `wearable`, `unknown`. - `operating-system`: Returns analytics based on the operating system used by the viewers. Response values can include `windows`, `mac osx`, `android`, `ios`, `linux`. - `browser`: Returns analytics based on the browser used by the viewers. Response values can include `chrome`, `firefox`, `edge`, `opera`. req.From(time.Now()) // time.Time | Use this query parameter to define the starting date-time of the period you want analytics for. - If you do not set a value for `from`, the default assigned value is 1 day ago, based on the `to` parameter. - The maximum value is 30 days ago. - The value you provide should follow the ATOM date-time format: `2024-02-05T00:00:00+01:00` req.To(time.Now()) // time.Time | Use this query parameter to define the ending date-time of the period you want analytics for. - If you do not set a value for `to`, the default assigned value is `now`. - The value for `to` is a non-inclusive value: the API returns data **before** the date-time that you set. + req.SortBy("metricValue") // string | Use this parameter to choose which field the API will use to sort the analytics data. These are the available fields to sort by: - `metricValue`: Sorts the results based on the **metric** you selected in your request. - `dimensionValue`: Sorts the results based on the **dimension** you selected in your request. + req.SortOrder("asc") // string | Use this parameter to define the sort order of results. These are the available sort orders: - `asc`: Sorts the results in ascending order: `A to Z` and `0 to 9`. - `desc`: Sorts the results in descending order: `Z to A` and `9 to 0`. req.FilterBy(map[string][]apivideosdk.FilterBy2{"key": "TODO"}) // FilterBy2 | Use this parameter to filter the API's response based on different data dimensions. You can serialize filters in your query to receive more detailed breakdowns of your analytics. - If you do not set a value for `filterBy`, the API returns the full dataset for your project. - The API only accepts the `mediaId` and `mediaType` filters when you call `/data/metrics/play/total` or `/data/buckets/play-total/media-id`. These are the available breakdown dimensions: - `mediaId`: Returns analytics based on the unique identifiers of a video or a live stream. - `mediaType`: Returns analytics based on the type of content. Possible values: `video` and `live-stream`. - `continent`: Returns analytics based on the viewers' continent. The list of supported continents names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `EU`. Possible values are: `AS`, `AF`, `NA`, `SA`, `AN`, `EU`, `AZ`. - `country`: Returns analytics based on the viewers' country. The list of supported country names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `FR`. - `deviceType`: Returns analytics based on the type of device used by the viewers. Response values can include: `computer`, `phone`, `tablet`, `tv`, `console`, `wearable`, `unknown`. - `operatingSystem`: Returns analytics based on the operating system used by the viewers. Response values can include `windows`, `mac osx`, `android`, `ios`, `linux`. - `browser`: Returns analytics based on the browser used by the viewers. Response values can include `chrome`, `firefox`, `edge`, `opera`. - `tag`: Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). req.CurrentPage(int32(2)) // int32 | Choose the number of search results to return per page. Minimum value: 1 (default to 1) req.PageSize(int32(30)) // int32 | Results per page. Allowed values 1-100, default is 25. (default to 25) @@ -151,6 +153,8 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **from** | **time.Time** | Use this query parameter to define the starting date-time of the period you want analytics for. - If you do not set a value for `from`, the default assigned value is 1 day ago, based on the `to` parameter. - The maximum value is 30 days ago. - The value you provide should follow the ATOM date-time format: `2024-02-05T00:00:00+01:00` | **to** | **time.Time** | Use this query parameter to define the ending date-time of the period you want analytics for. - If you do not set a value for `to`, the default assigned value is `now`. - The value for `to` is a non-inclusive value: the API returns data **before** the date-time that you set. | +**sortBy** | **string** | Use this parameter to choose which field the API will use to sort the analytics data. These are the available fields to sort by: - `metricValue`: Sorts the results based on the **metric** you selected in your request. - `dimensionValue`: Sorts the results based on the **dimension** you selected in your request. | +**sortOrder** | **string** | Use this parameter to define the sort order of results. These are the available sort orders: - `asc`: Sorts the results in ascending order: `A to Z` and `0 to 9`. - `desc`: Sorts the results in descending order: `Z to A` and `9 to 0`. | **filterBy** | [**FilterBy2**](FilterBy2.md) | Use this parameter to filter the API's response based on different data dimensions. You can serialize filters in your query to receive more detailed breakdowns of your analytics. - If you do not set a value for `filterBy`, the API returns the full dataset for your project. - The API only accepts the `mediaId` and `mediaType` filters when you call `/data/metrics/play/total` or `/data/buckets/play-total/media-id`. These are the available breakdown dimensions: - `mediaId`: Returns analytics based on the unique identifiers of a video or a live stream. - `mediaType`: Returns analytics based on the type of content. Possible values: `video` and `live-stream`. - `continent`: Returns analytics based on the viewers' continent. The list of supported continents names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `EU`. Possible values are: `AS`, `AF`, `NA`, `SA`, `AN`, `EU`, `AZ`. - `country`: Returns analytics based on the viewers' country. The list of supported country names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `FR`. - `deviceType`: Returns analytics based on the type of device used by the viewers. Response values can include: `computer`, `phone`, `tablet`, `tv`, `console`, `wearable`, `unknown`. - `operatingSystem`: Returns analytics based on the operating system used by the viewers. Response values can include `windows`, `mac osx`, `android`, `ios`, `linux`. - `browser`: Returns analytics based on the browser used by the viewers. Response values can include `chrome`, `firefox`, `edge`, `opera`. - `tag`: Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). | **currentPage** | **int32** | Choose the number of search results to return per page. Minimum value: 1 | [default to 1] **pageSize** | **int32** | Results per page. Allowed values 1-100, default is 25. | [default to 25] @@ -200,6 +204,8 @@ func main() { req.From(time.Now()) // time.Time | Use this query parameter to define the starting date-time of the period you want analytics for. - If you do not set a value for `from`, the default assigned value is 1 day ago, based on the `to` parameter. - The maximum value is 30 days ago. - The value you provide should follow the ATOM date-time format: `2024-02-05T00:00:00+01:00` req.To(time.Now()) // time.Time | Use this query parameter to define the ending date-time of the period you want analytics for. - If you do not set a value for `to`, the default assigned value is `now`. - The value for `to` is a non-inclusive value: the API returns data **before** the date-time that you set. req.Interval("hour") // string | Use this query parameter to define how granularity of the data. Possible values: `hour`, `day`. - Default: If no interval specified and the period (different between from and to) ≤ 2 days then hour, otherwise day. - If you do not set a value for `interval`, and the period you set using the `from` and `to` parameters is less than or equals to 2 days, then the default assigned value is `hour`. Otherwise the API sets it to `day`. + req.SortBy("metricValue") // string | Use this parameter to choose which field the API will use to sort the analytics data. These are the available fields to sort by: - `metricValue`: Sorts the results based on the **metric** you selected in your request. - `emittedAt`: Sorts the results based on the **timestamp** of the event in ATOM date-time format. + req.SortOrder("asc") // string | Use this parameter to define the sort order of results. These are the available sort orders: - `asc`: Sorts the results in ascending order: `A to Z` and `0 to 9`. - `desc`: Sorts the results in descending order: `Z to A` and `9 to 0`. req.FilterBy(map[string][]apivideosdk.FilterBy2{"key": "TODO"}) // FilterBy2 | Use this parameter to filter the API's response based on different data dimensions. You can serialize filters in your query to receive more detailed breakdowns of your analytics. - If you do not set a value for `filterBy`, the API returns the full dataset for your project. - The API only accepts the `mediaId` and `mediaType` filters when you call `/data/metrics/play/total` or `/data/buckets/play-total/media-id`. These are the available breakdown dimensions: - `mediaId`: Returns analytics based on the unique identifiers of a video or a live stream. - `mediaType`: Returns analytics based on the type of content. Possible values: `video` and `live-stream`. - `continent`: Returns analytics based on the viewers' continent. The list of supported continents names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `EU`. Possible values are: `AS`, `AF`, `NA`, `SA`, `AN`, `EU`, `AZ`. - `country`: Returns analytics based on the viewers' country. The list of supported country names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `FR`. - `deviceType`: Returns analytics based on the type of device used by the viewers. Response values can include: `computer`, `phone`, `tablet`, `tv`, `console`, `wearable`, `unknown`. - `operatingSystem`: Returns analytics based on the operating system used by the viewers. Response values can include `windows`, `mac osx`, `android`, `ios`, `linux`. - `browser`: Returns analytics based on the browser used by the viewers. Response values can include `chrome`, `firefox`, `edge`, `opera`. - `tag`: Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). req.CurrentPage(int32(2)) // int32 | Choose the number of search results to return per page. Minimum value: 1 (default to 1) req.PageSize(int32(30)) // int32 | Results per page. Allowed values 1-100, default is 25. (default to 25) @@ -230,6 +236,8 @@ Name | Type | Description | Notes **from** | **time.Time** | Use this query parameter to define the starting date-time of the period you want analytics for. - If you do not set a value for `from`, the default assigned value is 1 day ago, based on the `to` parameter. - The maximum value is 30 days ago. - The value you provide should follow the ATOM date-time format: `2024-02-05T00:00:00+01:00` | **to** | **time.Time** | Use this query parameter to define the ending date-time of the period you want analytics for. - If you do not set a value for `to`, the default assigned value is `now`. - The value for `to` is a non-inclusive value: the API returns data **before** the date-time that you set. | **interval** | **string** | Use this query parameter to define how granularity of the data. Possible values: `hour`, `day`. - Default: If no interval specified and the period (different between from and to) ≤ 2 days then hour, otherwise day. - If you do not set a value for `interval`, and the period you set using the `from` and `to` parameters is less than or equals to 2 days, then the default assigned value is `hour`. Otherwise the API sets it to `day`. | +**sortBy** | **string** | Use this parameter to choose which field the API will use to sort the analytics data. These are the available fields to sort by: - `metricValue`: Sorts the results based on the **metric** you selected in your request. - `emittedAt`: Sorts the results based on the **timestamp** of the event in ATOM date-time format. | +**sortOrder** | **string** | Use this parameter to define the sort order of results. These are the available sort orders: - `asc`: Sorts the results in ascending order: `A to Z` and `0 to 9`. - `desc`: Sorts the results in descending order: `Z to A` and `9 to 0`. | **filterBy** | [**FilterBy2**](FilterBy2.md) | Use this parameter to filter the API's response based on different data dimensions. You can serialize filters in your query to receive more detailed breakdowns of your analytics. - If you do not set a value for `filterBy`, the API returns the full dataset for your project. - The API only accepts the `mediaId` and `mediaType` filters when you call `/data/metrics/play/total` or `/data/buckets/play-total/media-id`. These are the available breakdown dimensions: - `mediaId`: Returns analytics based on the unique identifiers of a video or a live stream. - `mediaType`: Returns analytics based on the type of content. Possible values: `video` and `live-stream`. - `continent`: Returns analytics based on the viewers' continent. The list of supported continents names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `EU`. Possible values are: `AS`, `AF`, `NA`, `SA`, `AN`, `EU`, `AZ`. - `country`: Returns analytics based on the viewers' country. The list of supported country names are based on the [GeoNames public database](https://www.geonames.org/countries/). You must use the ISO-3166 alpha2 format, for example `FR`. - `deviceType`: Returns analytics based on the type of device used by the viewers. Response values can include: `computer`, `phone`, `tablet`, `tv`, `console`, `wearable`, `unknown`. - `operatingSystem`: Returns analytics based on the operating system used by the viewers. Response values can include `windows`, `mac osx`, `android`, `ios`, `linux`. - `browser`: Returns analytics based on the browser used by the viewers. Response values can include `chrome`, `firefox`, `edge`, `opera`. - `tag`: Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). | **currentPage** | **int32** | Choose the number of search results to return per page. Minimum value: 1 | [default to 1] **pageSize** | **int32** | Results per page. Allowed values 1-100, default is 25. | [default to 25]