diff --git a/omaha/omaha.go b/omaha/omaha.go index 3e98444..098bde3 100644 --- a/omaha/omaha.go +++ b/omaha/omaha.go @@ -70,7 +70,7 @@ type App struct { XMLName xml.Name `xml:"app"` Ping *Ping `xml:"ping"` UpdateCheck *UpdateCheck `xml:"updatecheck"` - Event *Event `xml:"event"` + Events []*Event `xml:"event"` Id string `xml:"appid,attr,omitempty"` Version string `xml:"version,attr,omitempty"` NextVersion string `xml:"nextversion,attr,omitempty"` @@ -96,12 +96,18 @@ func (a *App) AddPing() *Ping { return a.Ping } +func (a *App) AddEvent() *Event { + event := new(Event) + a.Events = append(a.Events, event) + return event +} + type UpdateCheck struct { - XMLName xml.Name `xml:"updatecheck"` - Urls *Urls `xml:"urls"` - Manifest *Manifest `xml:"manifest"` - TargetVersionPrefix string `xml:"targetversionprefix,attr,omitempty"` - Status string `xml:"status,attr,omitempty"` + XMLName xml.Name `xml:"updatecheck"` + Urls *Urls `xml:"urls"` + Manifest *Manifest `xml:"manifest"` + TargetVersionPrefix string `xml:"targetversionprefix,attr,omitempty"` + Status string `xml:"status,attr,omitempty"` } func (u *UpdateCheck) AddUrl(codebase string) *Url { @@ -182,7 +188,7 @@ func (m *Manifest) AddPackage(hash string, name string, size string, required bo } type Actions struct { - XMLName xml.Name `xml:"actions"` + XMLName xml.Name `xml:"actions"` Actions []*Action `xml:"action"` } diff --git a/omaha/omaha_test.go b/omaha/omaha_test.go index 80ac27b..ca43c41 100644 --- a/omaha/omaha_test.go +++ b/omaha/omaha_test.go @@ -40,7 +40,7 @@ func TestOmahaRequestUpdateCheck(t *testing.T) { t.Error("developer-build") } - if v.Apps[0].Event.Type != "3" { + if v.Apps[0].Events[0].Type != "3" { t.Error("developer-build") } } @@ -97,6 +97,10 @@ func ExampleOmaha_NewRequest() { app := request.AddApp("{27BD862E-8AE8-4886-A055-F7F1A6460627}", "1.0.0.0") app.AddUpdateCheck() + event := app.AddEvent() + event.Type = "1" + event.Result = "0" + if raw, err := xml.MarshalIndent(request, "", " "); err != nil { fmt.Println(err) return @@ -110,6 +114,7 @@ func ExampleOmaha_NewRequest() { // // // + // // // }