forked from emiddleton/gads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report_utils_test.go
107 lines (95 loc) · 2.4 KB
/
report_utils_test.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
package gads
import (
"testing"
"github.com/kr/pretty"
)
func testReportUtils(t *testing.T) (service *ReportUtils) {
return &ReportUtils{Auth: testAuthSetup(t)}
}
func TestDownloadBudgetPerformanceReportCustomDate(t *testing.T) {
ru := testReportUtils(t)
predicates := []Predicate{
{"AssociatedCampaignId", "EQUALS", []string{"246257700"}},
}
reportDefinition := &ReportDefinition{
Selector: Selector{
Fields: []string{
"AssociatedCampaignId",
"AverageCpc",
"AverageCpm",
"Cost",
"Clicks",
"Impressions",
"Conversions",
},
Predicates: predicates,
DateRange: &DateRange{
Min: "20150201", //YYYYMMDD
Max: "20150601", //YYYYMMDD
},
},
ReportName: "Report #553f5265b3d84",
DateRangeType: DATE_RANGE_CUSTOM_DATE,
IncludeZeroImpressions: true,
}
report, err := ru.DownloadBudgetPerformanceReport(reportDefinition)
pretty.Println(report)
pretty.Println(err)
}
func TestDownloadBudgetPerformanceReport(t *testing.T) {
ru := testReportUtils(t)
predicates := []Predicate{
{"AssociatedCampaignId", "EQUALS", []string{"246257700"}},
}
reportDefinition := &ReportDefinition{
Selector: Selector{
Fields: []string{
"AssociatedCampaignId",
"AverageCpc",
"AverageCpm",
"Cost",
"Clicks",
"Impressions",
"Conversions",
},
Predicates: predicates,
},
ReportName: "Report #553f5265b3d84",
DateRangeType: DATE_RANGE_ALL_TIME,
IncludeZeroImpressions: true,
}
report, err := ru.DownloadBudgetPerformanceReport(reportDefinition)
pretty.Println(report)
pretty.Println(err)
}
func TestDownloadCampaignPerformaceReport(t *testing.T) {
ru := testReportUtils(t)
predicates := []Predicate{
{"CampaignId", "EQUALS", []string{"246257700"}},
}
reportDefinition := &ReportDefinition{
Selector: Selector{
Fields: []string{
"CampaignId",
"AverageCpc",
"AverageCpm",
"Cost",
"Clicks",
"Impressions",
"Week", //Quarter, Month , Year, Week, Date
},
Predicates: predicates,
DateRange: &DateRange{
Min: "20150411", //YYYYMMDD
Max: "20150621", //YYYYMMDD
},
},
ReportName: "Report #553f5265b3d84",
// DateRangeType: DATE_RANGE_ALL_TIME,
DateRangeType: DATE_RANGE_CUSTOM_DATE,
IncludeZeroImpressions: true,
}
report, err := ru.DownloadCampaignPerformaceReport(reportDefinition)
pretty.Println(report)
pretty.Println(err)
}