2021-02-15 00:44:37 +00:00
|
|
|
package lifx
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/url"
|
|
|
|
"path"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BuildURL(rawurl, rawpath string) string {
|
|
|
|
u, _ := url.Parse(rawurl)
|
|
|
|
u.Path = path.Join(u.Path, rawpath)
|
|
|
|
return u.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
Endpoint = "https://api.lifx.com/v1"
|
|
|
|
EndpointState = func(selector string) string {
|
|
|
|
return BuildURL(Endpoint, fmt.Sprintf("/lights/%s/state", selector))
|
|
|
|
}
|
|
|
|
EndpointStateDelta = func(selector string) string {
|
|
|
|
return BuildURL(Endpoint, fmt.Sprintf("/lights/%s/state/delta", selector))
|
|
|
|
}
|
|
|
|
EndpointListLights = func(selector string) string {
|
|
|
|
return BuildURL(Endpoint, fmt.Sprintf("/lights/%s", selector))
|
|
|
|
}
|
|
|
|
EndpointStates = func() string {
|
|
|
|
return BuildURL(Endpoint, "/lights/states")
|
|
|
|
}
|
|
|
|
EndpointColor = func() string {
|
|
|
|
return BuildURL(Endpoint, "/color")
|
|
|
|
}
|
|
|
|
EndpointToggle = func(selector string) string {
|
|
|
|
return BuildURL(Endpoint, fmt.Sprintf("/lights/%s/toggle", selector))
|
|
|
|
}
|
2021-03-19 04:24:04 +00:00
|
|
|
EndpointBreathe = func(selector string) string {
|
2021-03-21 02:24:06 +00:00
|
|
|
return BuildURL(Endpoint, fmt.Sprintf("/lights/%s/effects/breathe", selector))
|
2021-03-19 04:24:04 +00:00
|
|
|
}
|
2021-02-15 00:44:37 +00:00
|
|
|
)
|