lume/structs.go

60 lines
1.0 KiB
Go
Raw Normal View History

2020-02-24 03:01:12 +00:00
package lifx
import (
"net/http"
)
const API_BASE_URL = "https://api.lifx.com/v1"
type (
2020-02-29 04:15:40 +00:00
Status string
2020-02-24 03:01:12 +00:00
State struct {
Power string `json:"power,omitempty"`
Color string `json:"color,omitempty"`
Brightness float64 `json:"brightness,omitempty"`
Duration float64 `json:"duration,omitempty"`
Infrared float64 `json:"infrared,omitempty"`
Fast bool `json:"fast,omitempty"`
}
2020-02-29 06:08:39 +00:00
StateWithSelector struct {
State
Selector string `json:"selector"`
}
States struct {
States []StateWithSelector `json:"states",omitempty`
Defaults State `json:"defaults",omitempty`
}
2020-02-29 03:56:33 +00:00
Client struct {
token string
Client *http.Client
2020-02-24 03:01:12 +00:00
}
Results struct {
Results []Result `json:results`
}
Result struct {
ID string `json:"id"`
Label string `json:"label"`
2020-02-29 04:14:55 +00:00
Status Status `json:"status"`
}
Toggle struct {
Duration float64 `json:"duration,omitempty"`
}
2020-02-24 03:01:12 +00:00
)
2020-02-29 04:15:40 +00:00
const (
OK Status = "ok"
TimedOut Status = "timed_out"
Offline Status = "offline"
)
func (s Status) Success() bool {
return s == OK
}