diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-01-28 20:08:26 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-01-28 20:08:26 -0500 |
commit | 27b9932aa92b7cf92d782aedbfb891747e52ea43 (patch) | |
tree | ffb0c0a399a52e7013775556a31e11f977e3387d | |
parent | 726f39d58986ad0b72dc0a94f0ad9d0138fb73a7 (diff) |
Condensed BridgeInfo struct into one with embedded structs.
-rw-r--r-- | bridge.go | 40 |
1 files changed, 23 insertions, 17 deletions
@@ -20,22 +20,20 @@ type Bridge struct { } type BridgeInfo struct { - XMLName xml.Name `xml:"root"` - Device Device `xml:"device"` -} - -type Device struct { - XMLName xml.Name `xml:"device"` - DeviceType string `xml:"deviceType"` - FriendlyName string `xml:"friendlyName"` - Manufacturer string `xml:"manufacturer"` - ManufacturerURL string `xml:"manufacturerURL"` - ModelDescription string `xml:"modelDescription"` - ModelName string `xml:"modelName"` - ModelNumber string `xml:"modelNumber"` - ModelURL string `xml:"modelURL"` - SerialNumber string `xml:"serialNumber"` - UDN string `xml:"UDN"` + Info struct { + Info struct { + DeviceType string `xml:"deviceType"` + FriendlyName string `xml:"friendlyName"` + Manufacturer string `xml:"manufacturer"` + ManufacturerURL string `xml:"manufacturerURL"` + ModelDescription string `xml:"modelDescription"` + ModelName string `xml:"modelName"` + ModelNumber string `xml:"modelNumber"` + ModelURL string `xml:"modelURL"` + SerialNumber string `xml:"serialNumber"` + UDN string `xml:"UDN"` + } `xml:"device"` + } `xml:"root"` } // NewBridge defines hardware that is compatible with Hue. @@ -104,7 +102,15 @@ func CreateUser(bridge *Bridge, deviceType string) (string, error) { } defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) - fmt.Println(string(body)) + log.Println(string(body)) + + data := []Error{} + err = json.Unmarshal(body, &data) + if err != nil { + trace("", err) + os.Exit(1) + } + fmt.Println(data) // TODO: decode and return // TODO: handle errors. http://www.developers.meethue.com/documentation/error-messages |