Compare commits
	
		
			2 Commits
		
	
	
		
			7ef6d66564
			...
			bba7c22460
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						bba7c22460
	
				 | 
					
					
						|||
| 
						
						
							
						
						4d496f7524
	
				 | 
					
					
						
@@ -9,12 +9,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	idWidth       int = 0
 | 
			
		||||
	locationWidth int = 0
 | 
			
		||||
	groupWidth    int = 0
 | 
			
		||||
	labelWidth    int = 0
 | 
			
		||||
	lastSeenWidth int = 0
 | 
			
		||||
	powerWidth    int = 0
 | 
			
		||||
	idWidth, locationWidth, groupWidth, labelWidth, lastSeenWidth, powerWidth int
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								lights.go
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								lights.go
									
									
									
									
									
								
							@@ -3,6 +3,7 @@ package lifx
 | 
			
		||||
import (
 | 
			
		||||
	//"crypto/tls"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
@@ -88,6 +89,17 @@ 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
 | 
			
		||||
}
 | 
			
		||||
@@ -170,6 +182,10 @@ 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
 | 
			
		||||
	}
 | 
			
		||||
@@ -189,6 +205,10 @@ 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
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user