use struct for toggle endpoint

This commit is contained in:
Ryan Cavicchioni 2020-02-28 22:14:55 -06:00
parent e05efa9d57
commit c0c49b6d7c
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
2 changed files with 6 additions and 4 deletions

View File

@ -75,9 +75,7 @@ func (s *Client) SetState(selector string, state *State) ([]Result, error) {
}
func (s *Client) Toggle(selector string, duration float64) ([]Result, error) {
m := make(map[string]interface{})
m["duration"] = duration
j, err := json.Marshal(m)
j, err := json.Marshal(&Toggle{Duration: duration})
if err != nil {
return nil, err
}

View File

@ -28,6 +28,10 @@ type (
Result struct {
ID string `json:"id"`
Label string `json:"label"`
Status string `json:"status"`
Status Status `json:"status"`
}
Toggle struct {
Duration float64 `json:"duration,omitempty"`
}
)