-
Notifications
You must be signed in to change notification settings - Fork 56
/
constant_data.go
181 lines (170 loc) · 4.78 KB
/
constant_data.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
package gads
import (
"encoding/xml"
)
type ConstantDataService struct {
Auth
}
func NewConstantDataService(auth *Auth) *ConstantDataService {
return &ConstantDataService{Auth: *auth}
}
func (s *ConstantDataService) GetAgeRangeCriterion() (ageRanges []AgeRangeCriterion, err error) {
respBody, err := s.Auth.request(
constantDataServiceUrl,
"getAgeRangeCriterion",
struct {
XMLName xml.Name `xml:"https://adwords.google.com/api/adwords/cm/v201309 getAgeRangeCriterion"`
}{},
)
if err != nil {
return ageRanges, err
}
getResp := struct {
AgeRangeCriterions []AgeRangeCriterion `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return ageRanges, err
}
return getResp.AgeRangeCriterions, err
}
func (s *ConstantDataService) GetCarrierCriterion() (carriers []CarrierCriterion, err error) {
respBody, err := s.Auth.request(
constantDataServiceUrl,
"getCarrierCriterion",
struct {
XMLName xml.Name `xml:"https://adwords.google.com/api/adwords/cm/v201309 getCarrierCriterion"`
}{},
)
if err != nil {
return carriers, err
}
getResp := struct {
CarrierCriterions []CarrierCriterion `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return carriers, err
}
return getResp.CarrierCriterions, err
}
func (s *ConstantDataService) GetGenderCriterion() (genders []GenderCriterion, err error) {
respBody, err := s.Auth.request(
constantDataServiceUrl,
"getGenderCriterion",
struct {
XMLName xml.Name `xml:"https://adwords.google.com/api/adwords/cm/v201309 getGenderCriterion"`
}{},
)
if err != nil {
return genders, err
}
getResp := struct {
GenderCriterions []GenderCriterion `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return genders, err
}
return getResp.GenderCriterions, err
}
func (s *ConstantDataService) GetLanguageCriterion() (languages []LanguageCriterion, err error) {
respBody, err := s.Auth.request(
constantDataServiceUrl,
"getLanguageCriterion",
struct {
XMLName xml.Name `xml:"https://adwords.google.com/api/adwords/cm/v201309 getLanguageCriterion"`
}{},
)
if err != nil {
return languages, err
}
getResp := struct {
LanguageCriterions []LanguageCriterion `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return languages, err
}
return getResp.LanguageCriterions, err
}
func (s *ConstantDataService) GetMobileDeviceCriterion() (mobileDevices []MobileDeviceCriterion, err error) {
respBody, err := s.Auth.request(
constantDataServiceUrl,
"getMobileDeviceCriterion",
struct {
XMLName xml.Name `xml:"https://adwords.google.com/api/adwords/cm/v201309 getMobileDeviceCriterion"`
}{},
)
if err != nil {
return mobileDevices, err
}
getResp := struct {
MobileDeviceCriterions []MobileDeviceCriterion `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return mobileDevices, err
}
return getResp.MobileDeviceCriterions, err
}
func (s *ConstantDataService) GetOperatingSystemVersionCriterion() (operatingSystemVersions []OperatingSystemVersionCriterion, err error) {
respBody, err := s.Auth.request(
constantDataServiceUrl,
"getOperatingSystemVersionCriterion",
struct {
XMLName xml.Name `xml:"https://adwords.google.com/api/adwords/cm/v201309 getOperatingSystemVersionCriterion"`
}{},
)
if err != nil {
return operatingSystemVersions, err
}
getResp := struct {
OperatingSystemVersionCriterions []OperatingSystemVersionCriterion `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return operatingSystemVersions, err
}
return getResp.OperatingSystemVersionCriterions, err
}
func (s *ConstantDataService) GetUserInterestCriterion() (userInterests []UserInterestCriterion, err error) {
respBody, err := s.Auth.request(
constantDataServiceUrl,
"getUserInterestCriterion",
struct {
XMLName xml.Name `xml:"https://adwords.google.com/api/adwords/cm/v201309 getUserInterestCriterion"`
}{},
)
if err != nil {
return userInterests, err
}
getResp := struct {
UserInterestCriterions []UserInterestCriterion `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return userInterests, err
}
return getResp.UserInterestCriterions, err
}
func (s *ConstantDataService) GetVerticalCriterion() (verticals []VerticalCriterion, err error) {
respBody, err := s.Auth.request(
constantDataServiceUrl,
"getVerticalCriterion",
struct {
XMLName xml.Name `xml:"https://adwords.google.com/api/adwords/cm/v201309 getVerticalCriterion"`
}{},
)
if err != nil {
return verticals, err
}
getResp := struct {
VerticalCriterions []VerticalCriterion `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return verticals, err
}
return getResp.VerticalCriterions, err
}