aboutsummaryrefslogtreecommitdiff
path: root/bridge.go
diff options
context:
space:
mode:
authorCollin Guarino <collin.guarino@gmail.com>2016-01-30 12:11:47 -0500
committerCollin Guarino <collin.guarino@gmail.com>2016-01-30 12:11:47 -0500
commit779dcafebdca3282c5bcd8855ab006ab7328e49c (patch)
treeaecbab93d60032da99b11e8d72e75377afd7bb6f /bridge.go
parent27b9932aa92b7cf92d782aedbfb891747e52ea43 (diff)
Hacky json parsing in CreateUser. Will fix later.
Diffstat (limited to 'bridge.go')
-rw-r--r--bridge.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/bridge.go b/bridge.go
index eda2f25..90a6f12 100644
--- a/bridge.go
+++ b/bridge.go
@@ -10,7 +10,9 @@ import (
"io/ioutil"
"runtime"
"fmt"
+ "strings"
"bytes"
+ "errors"
)
type Bridge struct {
@@ -102,20 +104,21 @@ func CreateUser(bridge *Bridge, deviceType string) (string, error) {
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
- log.Println(string(body))
-
- data := []Error{}
- err = json.Unmarshal(body, &data)
if err != nil {
trace("", err)
- os.Exit(1)
}
- fmt.Println(data)
+
+ result := string(body)
+ errFound := strings.Contains(result, "error")
+ noLink := strings.Contains(result, "link button not pressed")
+ if errFound && noLink {
+ return "", errors.New("Link button not pressed.")
+ }
// TODO: decode and return
// TODO: handle errors. http://www.developers.meethue.com/documentation/error-messages
- return "", err
+ return "", nil
}
// Log the date, time, file location, line number, and function.