-
Notifications
You must be signed in to change notification settings - Fork 56
/
negative_ad_group_criterion.go
55 lines (51 loc) · 1.3 KB
/
negative_ad_group_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
53
54
55
package gads
import (
"encoding/xml"
"fmt"
)
type NegativeAdGroupCriterion struct {
AdGroupId int64 `xml:"adGroupId"`
Criterion Criterion `xml:"criterion"`
}
func (nagc NegativeAdGroupCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
start.Attr = append(
start.Attr,
xml.Attr{
xml.Name{"http://www.w3.org/2001/XMLSchema-instance", "type"},
"NegativeAdGroupCriterion",
},
)
e.EncodeToken(start)
e.EncodeElement(&nagc.AdGroupId, xml.StartElement{Name: xml.Name{"", "adGroupId"}})
criterionMarshalXML(nagc.Criterion, e)
e.EncodeToken(start.End())
return nil
}
func (nagc *NegativeAdGroupCriterion) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error {
for token, err := dec.Token(); err == nil; token, err = dec.Token() {
if err != nil {
return err
}
switch start := token.(type) {
case xml.StartElement:
tag := start.Name.Local
switch tag {
case "adGroupId":
if err := dec.DecodeElement(&nagc.AdGroupId, &start); err != nil {
return err
}
case "criterion":
criterion, err := criterionUnmarshalXML(dec, start)
if err != nil {
return err
}
nagc.Criterion = criterion
case "AdGroupCriterion.Type":
break
default:
return fmt.Errorf("unknown NegativeAdGroupCriterion field %s", tag)
}
}
}
return nil
}