diff --git a/omaha.go b/omaha.go index bd16fe2..3e98444 100644 --- a/omaha.go +++ b/omaha.go @@ -70,8 +70,6 @@ type App struct { XMLName xml.Name `xml:"app"` Ping *Ping `xml:"ping"` UpdateCheck *UpdateCheck `xml:"updatecheck"` - Urls *Urls `xml:"urls"` - Manifest *Manifest `xml:"manifest"` Event *Event `xml:"event"` Id string `xml:"appid,attr,omitempty"` Version string `xml:"version,attr,omitempty"` @@ -98,27 +96,29 @@ func (a *App) AddPing() *Ping { return a.Ping } -func (a *App) AddUrl(codebase string) *Url { - if a.Urls == nil { - a.Urls = new(Urls) - } - u := new(Url) - u.CodeBase = codebase - a.Urls.Urls = append(a.Urls.Urls, *u) - return u -} - -func (a *App) AddManifest(version string) *Manifest { - a.Manifest = &Manifest{Version: version} - return a.Manifest -} - 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"` } +func (u *UpdateCheck) AddUrl(codebase string) *Url { + if u.Urls == nil { + u.Urls = new(Urls) + } + url := new(Url) + url.CodeBase = codebase + u.Urls.Urls = append(u.Urls.Urls, *url) + return url +} + +func (u *UpdateCheck) AddManifest(version string) *Manifest { + u.Manifest = &Manifest{Version: version} + return u.Manifest +} + type Ping struct { XMLName xml.Name `xml:"ping"` LastReportDays string `xml:"r,attr,omitempty"` diff --git a/omaha_test.go b/omaha_test.go index ac60ee3..1d4f0b2 100644 --- a/omaha_test.go +++ b/omaha_test.go @@ -53,8 +53,8 @@ func ExampleOmaha_NewResponse() { p.Status = "ok" u := app.AddUpdateCheck() u.Status = "ok" - app.AddUrl("http://localhost/updates") - m := app.AddManifest("9999.0.0") + u.AddUrl("http://localhost/updates") + m := u.AddManifest("9999.0.0") m.AddPackage("+LXvjiaPkeYDLHoNKlf9qbJwvnk=", "update.gz", "67546213", true) a := m.AddAction("postinstall") a.ChromeOSVersion = "9999.0.0" @@ -76,18 +76,19 @@ func ExampleOmaha_NewResponse() { // // // - // - // - // - // - // - // - // - // - // - // - // - // + // + // + // + // + // + // + // + // + // + // + // + // + // // // }