Compare commits
No commits in common. "bba7c22460cb323a94b7edf9aaf741ee2e4a45f6" and "7ef6d66564fba8dd5bd9af2ef83f31e8864616ee" have entirely different histories.
bba7c22460
...
7ef6d66564
@ -9,7 +9,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
idWidth, locationWidth, groupWidth, labelWidth, lastSeenWidth, powerWidth int
|
||||
idWidth int = 0
|
||||
locationWidth int = 0
|
||||
groupWidth int = 0
|
||||
labelWidth int = 0
|
||||
lastSeenWidth int = 0
|
||||
powerWidth int = 0
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
20
lights.go
20
lights.go
@ -3,7 +3,6 @@ package lifx
|
||||
import (
|
||||
//"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
@ -89,17 +88,6 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func NewAPIError(resp *http.Response) error {
|
||||
var (
|
||||
s *Response
|
||||
err error
|
||||
)
|
||||
if err = json.NewDecoder(resp.Body).Decode(&s); err != nil {
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("fatal: %s", s.Error)
|
||||
}
|
||||
|
||||
func (s Status) Success() bool {
|
||||
return s == OK
|
||||
}
|
||||
@ -182,10 +170,6 @@ func (c *Client) Toggle(selector string, duration float64) (*Response, error) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode > 299 {
|
||||
return nil, NewAPIError(resp)
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(resp.Body).Decode(&s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -205,10 +189,6 @@ func (c *Client) ListLights(selector string) ([]Light, error) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode > 299 {
|
||||
return nil, NewAPIError(resp)
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(resp.Body).Decode(&s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user