diff --git a/client.go b/client.go index 9572cc7..4bf30b3 100644 --- a/client.go +++ b/client.go @@ -74,6 +74,20 @@ func (s *Client) SetState(selector string, state State) ([]Result, error) { return res, nil } +func (s *Client) SetStates(states States) ([]Result, error) { + j, err := json.Marshal(states) + if err != nil { + return nil, err + } + + res, err := s.Request("PUT", EndpointStates(), bytes.NewBuffer(j)) + if err != nil { + return nil, err + } + + return res, nil +} + func (s *Client) Toggle(selector string, duration float64) ([]Result, error) { j, err := json.Marshal(&Toggle{Duration: duration}) if err != nil { diff --git a/endpoints.go b/endpoints.go index ba1f703..2c72109 100644 --- a/endpoints.go +++ b/endpoints.go @@ -17,6 +17,9 @@ var ( EndpointState = func(selector string) string { return BuildURL(Endpoint, fmt.Sprintf("/lights/%s/state", selector)) } + EndpointStates = func() string { + return BuildURL(Endpoint, "/lights/states") + } EndpointToggle = func(selector string) string { return BuildURL(Endpoint, fmt.Sprintf("/lights/%s/toggle", selector)) } diff --git a/structs.go b/structs.go index c4ac65a..4e414b1 100644 --- a/structs.go +++ b/structs.go @@ -18,6 +18,16 @@ type ( Fast bool `json:"fast,omitempty"` } + StateWithSelector struct { + State + Selector string `json:"selector"` + } + + States struct { + States []StateWithSelector `json:"states",omitempty` + Defaults State `json:"defaults",omitempty` + } + Client struct { token string Client *http.Client