-
Notifications
You must be signed in to change notification settings - Fork 4
/
api_analytics.go
441 lines (373 loc) · 34.2 KB
/
api_analytics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
/*
* api.video
*
* api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes.
*
* API version: 1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package apivideosdk
import (
"context"
"net/http"
"net/url"
"strings"
"time"
)
// Linger please
var (
_ context.Context
)
type AnalyticsApiGetAggregatedMetricsRequest struct {
from *time.Time
to *time.Time
unique *bool
viewDuration *string
filterBy *FilterBy2
}
func (r AnalyticsApiGetAggregatedMetricsRequest) From(from time.Time) AnalyticsApiGetAggregatedMetricsRequest {
r.from = &from
return r
}
func (r AnalyticsApiGetAggregatedMetricsRequest) To(to time.Time) AnalyticsApiGetAggregatedMetricsRequest {
r.to = &to
return r
}
func (r AnalyticsApiGetAggregatedMetricsRequest) Unique(unique bool) AnalyticsApiGetAggregatedMetricsRequest {
r.unique = &unique
return r
}
func (r AnalyticsApiGetAggregatedMetricsRequest) ViewDuration(viewDuration string) AnalyticsApiGetAggregatedMetricsRequest {
r.viewDuration = &viewDuration
return r
}
func (r AnalyticsApiGetAggregatedMetricsRequest) FilterBy(filterBy FilterBy2) AnalyticsApiGetAggregatedMetricsRequest {
r.filterBy = &filterBy
return r
}
type AnalyticsApiGetMetricsBreakdownRequest struct {
from *time.Time
to *time.Time
sortBy *string
sortOrder *string
unique *bool
viewDuration *string
filterBy *FilterBy2
currentPage *int32
pageSize *int32
}
func (r AnalyticsApiGetMetricsBreakdownRequest) From(from time.Time) AnalyticsApiGetMetricsBreakdownRequest {
r.from = &from
return r
}
func (r AnalyticsApiGetMetricsBreakdownRequest) To(to time.Time) AnalyticsApiGetMetricsBreakdownRequest {
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) Unique(unique bool) AnalyticsApiGetMetricsBreakdownRequest {
r.unique = &unique
return r
}
func (r AnalyticsApiGetMetricsBreakdownRequest) ViewDuration(viewDuration string) AnalyticsApiGetMetricsBreakdownRequest {
r.viewDuration = &viewDuration
return r
}
func (r AnalyticsApiGetMetricsBreakdownRequest) FilterBy(filterBy FilterBy2) AnalyticsApiGetMetricsBreakdownRequest {
r.filterBy = &filterBy
return r
}
func (r AnalyticsApiGetMetricsBreakdownRequest) CurrentPage(currentPage int32) AnalyticsApiGetMetricsBreakdownRequest {
r.currentPage = ¤tPage
return r
}
func (r AnalyticsApiGetMetricsBreakdownRequest) PageSize(pageSize int32) AnalyticsApiGetMetricsBreakdownRequest {
r.pageSize = &pageSize
return r
}
type AnalyticsApiGetMetricsOverTimeRequest struct {
from *time.Time
to *time.Time
interval *string
sortBy *string
sortOrder *string
unique *bool
viewDuration *string
filterBy *FilterBy2
currentPage *int32
pageSize *int32
}
func (r AnalyticsApiGetMetricsOverTimeRequest) From(from time.Time) AnalyticsApiGetMetricsOverTimeRequest {
r.from = &from
return r
}
func (r AnalyticsApiGetMetricsOverTimeRequest) To(to time.Time) AnalyticsApiGetMetricsOverTimeRequest {
r.to = &to
return r
}
func (r AnalyticsApiGetMetricsOverTimeRequest) Interval(interval string) AnalyticsApiGetMetricsOverTimeRequest {
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) Unique(unique bool) AnalyticsApiGetMetricsOverTimeRequest {
r.unique = &unique
return r
}
func (r AnalyticsApiGetMetricsOverTimeRequest) ViewDuration(viewDuration string) AnalyticsApiGetMetricsOverTimeRequest {
r.viewDuration = &viewDuration
return r
}
func (r AnalyticsApiGetMetricsOverTimeRequest) FilterBy(filterBy FilterBy2) AnalyticsApiGetMetricsOverTimeRequest {
r.filterBy = &filterBy
return r
}
func (r AnalyticsApiGetMetricsOverTimeRequest) CurrentPage(currentPage int32) AnalyticsApiGetMetricsOverTimeRequest {
r.currentPage = ¤tPage
return r
}
func (r AnalyticsApiGetMetricsOverTimeRequest) PageSize(pageSize int32) AnalyticsApiGetMetricsOverTimeRequest {
r.pageSize = &pageSize
return r
}
type AnalyticsServiceI interface {
/*
* GetAggregatedMetrics Retrieve aggregated metrics
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. You can use the aggregations `count`, `rate`, and `total` with the `play` metric. - `start` is the number of times playback was started. You can use the aggregation `count` with this metric. - `end` is the number of times playback has ended with the content watch until the end. You can use the aggregation `count` with this metric. - `impression` is the number of times your content has been loaded and was ready for playback. You can use the aggregation `count` with this metric. - `impression-time` is the time in milliseconds that your content was loading for until the first video frame is displayed. You can use the aggregations `average` and `sum` with this metric. - `watch-time` is the cumulative time in seconds that the user has spent watching your content. You can use the aggregations `average` and `sum` with this metric. - `ccv`: is the number of concurrent viewers, or users watching at the same time. - `view`: the total number of viewers until this point in time.
* @param aggregation Use this path parameter to define a way of collecting data for the metric that you want analytics for. - `count` returns the overall number of events for the `play` metric. - `rate` returns the ratio that calculates the number of plays your content receives divided by its impressions. This aggregation can be used only with the `play` metric. - `total` calculates the total number of events for the `play` metric. - `average` calculates an average value for the selected metric. - `sum` adds up the total value of the select metric. - `peak` shows the highest value of the `ccv` metric in the timeframe of your request. You can use this aggregation only with the `ccv` metric. - `live` shows the highest value of the `ccv` metric from the last 20 seconds. You can use this aggregation only with the `ccv` metric.
* @return AnalyticsApiGetAggregatedMetricsRequest
*/
GetAggregatedMetrics(metric string, aggregation string, r AnalyticsApiGetAggregatedMetricsRequest) (*AnalyticsAggregatedMetricsResponse, error)
/*
* GetAggregatedMetrics Retrieve aggregated metrics
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. You can use the aggregations `count`, `rate`, and `total` with the `play` metric. - `start` is the number of times playback was started. You can use the aggregation `count` with this metric. - `end` is the number of times playback has ended with the content watch until the end. You can use the aggregation `count` with this metric. - `impression` is the number of times your content has been loaded and was ready for playback. You can use the aggregation `count` with this metric. - `impression-time` is the time in milliseconds that your content was loading for until the first video frame is displayed. You can use the aggregations `average` and `sum` with this metric. - `watch-time` is the cumulative time in seconds that the user has spent watching your content. You can use the aggregations `average` and `sum` with this metric. - `ccv`: is the number of concurrent viewers, or users watching at the same time. - `view`: the total number of viewers until this point in time.
* @param aggregation Use this path parameter to define a way of collecting data for the metric that you want analytics for. - `count` returns the overall number of events for the `play` metric. - `rate` returns the ratio that calculates the number of plays your content receives divided by its impressions. This aggregation can be used only with the `play` metric. - `total` calculates the total number of events for the `play` metric. - `average` calculates an average value for the selected metric. - `sum` adds up the total value of the select metric. - `peak` shows the highest value of the `ccv` metric in the timeframe of your request. You can use this aggregation only with the `ccv` metric. - `live` shows the highest value of the `ccv` metric from the last 20 seconds. You can use this aggregation only with the `ccv` metric.
* @return AnalyticsApiGetAggregatedMetricsRequest
*/
GetAggregatedMetricsWithContext(ctx context.Context, metric string, aggregation string, r AnalyticsApiGetAggregatedMetricsRequest) (*AnalyticsAggregatedMetricsResponse, error)
/*
* GetMetricsBreakdown Retrieve metrics in a breakdown of dimensions
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. - `play-rate` is the ratio that calculates the number of plays your content receives divided by its impressions. - `play-total` is the total number of times a specific content has been played. You can only use the `media-id` breakdown with this metric. - `start` is the number of times playback was started. - `end` is the number of times playback has ended with the content watch until the end. - `impression` is the number of times your content has been loaded and was ready for playback. - `ccv-peak` is the highest number of concurrent viewers in the timeframe of your request. - `ccv-average` is the average number of concurrent viewers in the timeframe of your request. - `view` is the total number of viewers until this point in time.
* @param breakdown 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`. - `referrer`: Returns the URL where the view originates from, for example a website where the video is embedded. View events from Android and iOS return empty strings as the value for `referrer`.
* @return AnalyticsApiGetMetricsBreakdownRequest
*/
GetMetricsBreakdown(metric string, breakdown string, r AnalyticsApiGetMetricsBreakdownRequest) (*AnalyticsMetricsBreakdownResponse, error)
/*
* GetMetricsBreakdown Retrieve metrics in a breakdown of dimensions
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. - `play-rate` is the ratio that calculates the number of plays your content receives divided by its impressions. - `play-total` is the total number of times a specific content has been played. You can only use the `media-id` breakdown with this metric. - `start` is the number of times playback was started. - `end` is the number of times playback has ended with the content watch until the end. - `impression` is the number of times your content has been loaded and was ready for playback. - `ccv-peak` is the highest number of concurrent viewers in the timeframe of your request. - `ccv-average` is the average number of concurrent viewers in the timeframe of your request. - `view` is the total number of viewers until this point in time.
* @param breakdown 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`. - `referrer`: Returns the URL where the view originates from, for example a website where the video is embedded. View events from Android and iOS return empty strings as the value for `referrer`.
* @return AnalyticsApiGetMetricsBreakdownRequest
*/
GetMetricsBreakdownWithContext(ctx context.Context, metric string, breakdown string, r AnalyticsApiGetMetricsBreakdownRequest) (*AnalyticsMetricsBreakdownResponse, error)
/*
* GetMetricsOverTime Retrieve metrics over time
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. - `play-rate` is the ratio that calculates the number of plays your content receives divided by its impressions. - `start` is the number of times playback was started. - `end` is the number of times playback has ended with the content watch until the end. - `impression` is the number of times your content has been loaded and was ready for playback. - `ccv-peak` is the highest number of concurrent viewers in the timeframe of your request. - `ccv-average` is the average number of concurrent viewers in the timeframe of your request. - `view` is the total number of viewers.
* @return AnalyticsApiGetMetricsOverTimeRequest
*/
GetMetricsOverTime(metric string, r AnalyticsApiGetMetricsOverTimeRequest) (*AnalyticsMetricsOverTimeResponse, error)
/*
* GetMetricsOverTime Retrieve metrics over time
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. - `play-rate` is the ratio that calculates the number of plays your content receives divided by its impressions. - `start` is the number of times playback was started. - `end` is the number of times playback has ended with the content watch until the end. - `impression` is the number of times your content has been loaded and was ready for playback. - `ccv-peak` is the highest number of concurrent viewers in the timeframe of your request. - `ccv-average` is the average number of concurrent viewers in the timeframe of your request. - `view` is the total number of viewers.
* @return AnalyticsApiGetMetricsOverTimeRequest
*/
GetMetricsOverTimeWithContext(ctx context.Context, metric string, r AnalyticsApiGetMetricsOverTimeRequest) (*AnalyticsMetricsOverTimeResponse, error)
}
// AnalyticsService communicating with the Analytics
// endpoints of the api.video API
type AnalyticsService struct {
client *Client
}
/*
* GetAggregatedMetrics Retrieve aggregated metrics
* Retrieve time-based and countable metrics like average watch time or the number of impressions over a certain period of time.
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. You can use the aggregations `count`, `rate`, and `total` with the `play` metric. - `start` is the number of times playback was started. You can use the aggregation `count` with this metric. - `end` is the number of times playback has ended with the content watch until the end. You can use the aggregation `count` with this metric. - `impression` is the number of times your content has been loaded and was ready for playback. You can use the aggregation `count` with this metric. - `impression-time` is the time in milliseconds that your content was loading for until the first video frame is displayed. You can use the aggregations `average` and `sum` with this metric. - `watch-time` is the cumulative time in seconds that the user has spent watching your content. You can use the aggregations `average` and `sum` with this metric. - `ccv`: is the number of concurrent viewers, or users watching at the same time. - `view`: the total number of viewers until this point in time.
* @param aggregation Use this path parameter to define a way of collecting data for the metric that you want analytics for. - `count` returns the overall number of events for the `play` metric. - `rate` returns the ratio that calculates the number of plays your content receives divided by its impressions. This aggregation can be used only with the `play` metric. - `total` calculates the total number of events for the `play` metric. - `average` calculates an average value for the selected metric. - `sum` adds up the total value of the select metric. - `peak` shows the highest value of the `ccv` metric in the timeframe of your request. You can use this aggregation only with the `ccv` metric. - `live` shows the highest value of the `ccv` metric from the last 20 seconds. You can use this aggregation only with the `ccv` metric.
* @return AnalyticsApiGetAggregatedMetricsRequest
*/
func (s *AnalyticsService) GetAggregatedMetrics(metric string, aggregation string, r AnalyticsApiGetAggregatedMetricsRequest) (*AnalyticsAggregatedMetricsResponse, error) {
return s.GetAggregatedMetricsWithContext(context.Background(), metric, aggregation, r)
}
/*
* GetAggregatedMetrics Retrieve aggregated metrics
* Retrieve time-based and countable metrics like average watch time or the number of impressions over a certain period of time.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. You can use the aggregations `count`, `rate`, and `total` with the `play` metric. - `start` is the number of times playback was started. You can use the aggregation `count` with this metric. - `end` is the number of times playback has ended with the content watch until the end. You can use the aggregation `count` with this metric. - `impression` is the number of times your content has been loaded and was ready for playback. You can use the aggregation `count` with this metric. - `impression-time` is the time in milliseconds that your content was loading for until the first video frame is displayed. You can use the aggregations `average` and `sum` with this metric. - `watch-time` is the cumulative time in seconds that the user has spent watching your content. You can use the aggregations `average` and `sum` with this metric. - `ccv`: is the number of concurrent viewers, or users watching at the same time. - `view`: the total number of viewers until this point in time.
* @param aggregation Use this path parameter to define a way of collecting data for the metric that you want analytics for. - `count` returns the overall number of events for the `play` metric. - `rate` returns the ratio that calculates the number of plays your content receives divided by its impressions. This aggregation can be used only with the `play` metric. - `total` calculates the total number of events for the `play` metric. - `average` calculates an average value for the selected metric. - `sum` adds up the total value of the select metric. - `peak` shows the highest value of the `ccv` metric in the timeframe of your request. You can use this aggregation only with the `ccv` metric. - `live` shows the highest value of the `ccv` metric from the last 20 seconds. You can use this aggregation only with the `ccv` metric.
* @return AnalyticsApiGetAggregatedMetricsRequest
*/
func (s *AnalyticsService) GetAggregatedMetricsWithContext(ctx context.Context, metric string, aggregation string, r AnalyticsApiGetAggregatedMetricsRequest) (*AnalyticsAggregatedMetricsResponse, error) {
var localVarPostBody interface{}
localVarPath := "/data/metrics/{metric}/{aggregation}"
localVarPath = strings.Replace(localVarPath, "{"+"metric"+"}", url.PathEscape(parameterToString(metric, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"aggregation"+"}", url.PathEscape(parameterToString(aggregation, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
if r.from != nil {
localVarQueryParams.Add("from", parameterToString(*r.from, ""))
}
if r.to != nil {
localVarQueryParams.Add("to", parameterToString(*r.to, ""))
}
if r.unique != nil {
localVarQueryParams.Add("unique", parameterToString(*r.unique, ""))
}
if r.viewDuration != nil {
localVarQueryParams.Add("viewDuration", parameterToString(*r.viewDuration, ""))
}
if r.filterBy != nil {
addDeepQueryParams(r.filterBy, "filterBy", localVarQueryParams)
}
req, err := s.client.prepareRequest(ctx, http.MethodGet, localVarPath, localVarPostBody, localVarHeaderParams, localVarQueryParams)
if err != nil {
return nil, err
}
res := new(AnalyticsAggregatedMetricsResponse)
_, err = s.client.do(req, res)
if err != nil {
return nil, err
}
return res, nil
}
/*
* GetMetricsBreakdown Retrieve metrics in a breakdown of dimensions
* Retrieve detailed analytics play-rate and number of impressions segmented by dimensions like country or device type.
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. - `play-rate` is the ratio that calculates the number of plays your content receives divided by its impressions. - `play-total` is the total number of times a specific content has been played. You can only use the `media-id` breakdown with this metric. - `start` is the number of times playback was started. - `end` is the number of times playback has ended with the content watch until the end. - `impression` is the number of times your content has been loaded and was ready for playback. - `ccv-peak` is the highest number of concurrent viewers in the timeframe of your request. - `ccv-average` is the average number of concurrent viewers in the timeframe of your request. - `view` is the total number of viewers until this point in time.
* @param breakdown 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`. - `referrer`: Returns the URL where the view originates from, for example a website where the video is embedded. View events from Android and iOS return empty strings as the value for `referrer`.
* @return AnalyticsApiGetMetricsBreakdownRequest
*/
func (s *AnalyticsService) GetMetricsBreakdown(metric string, breakdown string, r AnalyticsApiGetMetricsBreakdownRequest) (*AnalyticsMetricsBreakdownResponse, error) {
return s.GetMetricsBreakdownWithContext(context.Background(), metric, breakdown, r)
}
/*
* GetMetricsBreakdown Retrieve metrics in a breakdown of dimensions
* Retrieve detailed analytics play-rate and number of impressions segmented by dimensions like country or device type.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. - `play-rate` is the ratio that calculates the number of plays your content receives divided by its impressions. - `play-total` is the total number of times a specific content has been played. You can only use the `media-id` breakdown with this metric. - `start` is the number of times playback was started. - `end` is the number of times playback has ended with the content watch until the end. - `impression` is the number of times your content has been loaded and was ready for playback. - `ccv-peak` is the highest number of concurrent viewers in the timeframe of your request. - `ccv-average` is the average number of concurrent viewers in the timeframe of your request. - `view` is the total number of viewers until this point in time.
* @param breakdown 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`. - `referrer`: Returns the URL where the view originates from, for example a website where the video is embedded. View events from Android and iOS return empty strings as the value for `referrer`.
* @return AnalyticsApiGetMetricsBreakdownRequest
*/
func (s *AnalyticsService) GetMetricsBreakdownWithContext(ctx context.Context, metric string, breakdown string, r AnalyticsApiGetMetricsBreakdownRequest) (*AnalyticsMetricsBreakdownResponse, error) {
var localVarPostBody interface{}
localVarPath := "/data/buckets/{metric}/{breakdown}"
localVarPath = strings.Replace(localVarPath, "{"+"metric"+"}", url.PathEscape(parameterToString(metric, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"breakdown"+"}", url.PathEscape(parameterToString(breakdown, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
if r.from != nil {
localVarQueryParams.Add("from", parameterToString(*r.from, ""))
}
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.unique != nil {
localVarQueryParams.Add("unique", parameterToString(*r.unique, ""))
}
if r.viewDuration != nil {
localVarQueryParams.Add("viewDuration", parameterToString(*r.viewDuration, ""))
}
if r.filterBy != nil {
addDeepQueryParams(r.filterBy, "filterBy", localVarQueryParams)
}
if r.currentPage != nil {
localVarQueryParams.Add("currentPage", parameterToString(*r.currentPage, ""))
}
if r.pageSize != nil {
localVarQueryParams.Add("pageSize", parameterToString(*r.pageSize, ""))
}
req, err := s.client.prepareRequest(ctx, http.MethodGet, localVarPath, localVarPostBody, localVarHeaderParams, localVarQueryParams)
if err != nil {
return nil, err
}
res := new(AnalyticsMetricsBreakdownResponse)
_, err = s.client.do(req, res)
if err != nil {
return nil, err
}
return res, nil
}
/*
* GetMetricsOverTime Retrieve metrics over time
* Retrieve countable metrics like the number of plays or impressions, grouped by the time at which they occurred
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. - `play-rate` is the ratio that calculates the number of plays your content receives divided by its impressions. - `start` is the number of times playback was started. - `end` is the number of times playback has ended with the content watch until the end. - `impression` is the number of times your content has been loaded and was ready for playback. - `ccv-peak` is the highest number of concurrent viewers in the timeframe of your request. - `ccv-average` is the average number of concurrent viewers in the timeframe of your request. - `view` is the total number of viewers.
* @return AnalyticsApiGetMetricsOverTimeRequest
*/
func (s *AnalyticsService) GetMetricsOverTime(metric string, r AnalyticsApiGetMetricsOverTimeRequest) (*AnalyticsMetricsOverTimeResponse, error) {
return s.GetMetricsOverTimeWithContext(context.Background(), metric, r)
}
/*
* GetMetricsOverTime Retrieve metrics over time
* Retrieve countable metrics like the number of plays or impressions, grouped by the time at which they occurred
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param metric Use this path parameter to select a metric that you want analytics for. - `play` is the number of times your content has been played. - `play-rate` is the ratio that calculates the number of plays your content receives divided by its impressions. - `start` is the number of times playback was started. - `end` is the number of times playback has ended with the content watch until the end. - `impression` is the number of times your content has been loaded and was ready for playback. - `ccv-peak` is the highest number of concurrent viewers in the timeframe of your request. - `ccv-average` is the average number of concurrent viewers in the timeframe of your request. - `view` is the total number of viewers.
* @return AnalyticsApiGetMetricsOverTimeRequest
*/
func (s *AnalyticsService) GetMetricsOverTimeWithContext(ctx context.Context, metric string, r AnalyticsApiGetMetricsOverTimeRequest) (*AnalyticsMetricsOverTimeResponse, error) {
var localVarPostBody interface{}
localVarPath := "/data/timeseries/{metric}"
localVarPath = strings.Replace(localVarPath, "{"+"metric"+"}", url.PathEscape(parameterToString(metric, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
if r.from != nil {
localVarQueryParams.Add("from", parameterToString(*r.from, ""))
}
if r.to != nil {
localVarQueryParams.Add("to", parameterToString(*r.to, ""))
}
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.unique != nil {
localVarQueryParams.Add("unique", parameterToString(*r.unique, ""))
}
if r.viewDuration != nil {
localVarQueryParams.Add("viewDuration", parameterToString(*r.viewDuration, ""))
}
if r.filterBy != nil {
addDeepQueryParams(r.filterBy, "filterBy", localVarQueryParams)
}
if r.currentPage != nil {
localVarQueryParams.Add("currentPage", parameterToString(*r.currentPage, ""))
}
if r.pageSize != nil {
localVarQueryParams.Add("pageSize", parameterToString(*r.pageSize, ""))
}
req, err := s.client.prepareRequest(ctx, http.MethodGet, localVarPath, localVarPostBody, localVarHeaderParams, localVarQueryParams)
if err != nil {
return nil, err
}
res := new(AnalyticsMetricsOverTimeResponse)
_, err = s.client.do(req, res)
if err != nil {
return nil, err
}
return res, nil
}