-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_report_payload.go
81 lines (71 loc) · 2.23 KB
/
run_report_payload.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
package ga4data
import analyticsdata "google.golang.org/api/analyticsdata/v1beta"
// CreateRunReportRequest :
func CreateRunReportRequest(
dr analyticsdata.DateRange,
options ...func(req *analyticsdata.RunReportRequest),
) *analyticsdata.RunReportRequest {
req := &analyticsdata.RunReportRequest{
DateRanges: []*analyticsdata.DateRange{&dr},
}
for _, option := range options {
option(req)
}
return req
}
// RunReportRequestWithDimensionFilter :
func RunReportRequestWithDimensionFilter(filter *analyticsdata.FilterExpression) func(*analyticsdata.RunReportRequest) {
return func(req *analyticsdata.RunReportRequest) {
req.DimensionFilter = filter
}
}
// RunReportRequestWithMetricFilter :
func RunReportRequestWithMetricFilter(filter *analyticsdata.FilterExpression) func(*analyticsdata.RunReportRequest) {
return func(req *analyticsdata.RunReportRequest) {
req.MetricFilter = filter
}
}
// RunReportRequestWithPropertyQuota :
func RunReportRequestWithPropertyQuota() func(*analyticsdata.RunReportRequest) {
return func(req *analyticsdata.RunReportRequest) {
req.ReturnPropertyQuota = true
}
}
// RunReportRequestWithDimensions :
func RunReportRequestWithDimensions(dimensions []string) func(*analyticsdata.RunReportRequest) {
return func(req *analyticsdata.RunReportRequest) {
req.Dimensions = Dimensions(dimensions)
}
}
// RunReportRequestWithMetrics :
func RunReportRequestWithMetrics(metrics []string) func(*analyticsdata.RunReportRequest) {
return func(req *analyticsdata.RunReportRequest) {
req.Metrics = Metrics(metrics)
}
}
// Dimensions :
func Dimensions(dimensions []string) []*analyticsdata.Dimension {
dims := make([]*analyticsdata.Dimension, len(dimensions))
for i := range dims {
dims[i] = &analyticsdata.Dimension{
Name: dimensions[i],
}
}
return dims
}
// RunReportRequestWithMetricAggregations :
func RunReportRequestWithMetricAggregations(values []string) func(*analyticsdata.RunReportRequest) {
return func(req *analyticsdata.RunReportRequest) {
req.MetricAggregations = values
}
}
// Metrics :
func Metrics(metrics []string) []*analyticsdata.Metric {
mets := make([]*analyticsdata.Metric, len(metrics))
for i := range mets {
mets[i] = &analyticsdata.Metric{
Name: metrics[i],
}
}
return mets
}