From d8ad567e7f71f34e3b6a0af5d3261b2ed5f5a4b5 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Fri, 12 May 2017 12:56:21 -0700 Subject: [PATCH] protocol: add GetApp helper methods --- omaha/protocol.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/omaha/protocol.go b/omaha/protocol.go index 98cce51..0cc4aa5 100644 --- a/omaha/protocol.go +++ b/omaha/protocol.go @@ -79,6 +79,15 @@ func (r *Request) AddApp(id, version string) *AppRequest { return a } +func (r *Request) GetApp(id string) *AppRequest { + for _, app := range r.Apps { + if app.ID == id { + return app + } + } + return nil +} + type AppRequest struct { Ping *PingRequest `xml:"ping"` UpdateCheck *UpdateRequest `xml:"updatecheck"` @@ -181,6 +190,15 @@ func (r *Response) AddApp(id string, status AppStatus) *AppResponse { return a } +func (r *Response) GetApp(id string) *AppResponse { + for _, app := range r.Apps { + if app.ID == id { + return app + } + } + return nil +} + type AppResponse struct { Ping *PingResponse `xml:"ping"` UpdateCheck *UpdateResponse `xml:"updatecheck"`