-
Notifications
You must be signed in to change notification settings - Fork 56
/
location_criterion.go
52 lines (46 loc) · 1.16 KB
/
location_criterion.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
package gads
import (
"encoding/xml"
)
type LocationCriterionService struct {
Auth
}
func NewLocationCriterionService(auth *Auth) *LocationCriterionService {
return &LocationCriterionService{Auth: *auth}
}
type LocationCriterion struct {
Location Location `xml:"location"`
CanonicalName string `xml:"canonicalName,omitempty"`
Reach string `xml:"reach,omitempty"`
Locale string `xml:"locale,omitempty"`
SearchTerm string `xml:"searchTerm"`
}
type LocationCriterions []LocationCriterion
func (s *LocationCriterionService) Get(selector Selector) (locationCriterions LocationCriterions, err error) {
selector.XMLName = xml.Name{"", "selector"}
respBody, err := s.Auth.request(
locationCriterionServiceUrl,
"get",
struct {
XMLName xml.Name
Sel Selector
}{
XMLName: xml.Name{
Space: baseUrl,
Local: "get",
},
Sel: selector,
},
)
if err != nil {
return locationCriterions, err
}
getResp := struct {
LocationCriterions LocationCriterions `xml:"rval"`
}{}
err = xml.Unmarshal([]byte(respBody), &getResp)
if err != nil {
return locationCriterions, err
}
return getResp.LocationCriterions, err
}