blob: 2451457a5d15d3b051879e3eed9f715a525c13b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package octoprintApis
import (
"bytes"
"encoding/json"
// "fmt"
"io"
// "strings"
// "github.com/Z-Bolt/OctoScreen/octoprintApis/dataModels"
)
// ToolSelectRequest selects the printer’s current tool.
type ToolSelectRequest struct {
// Tool to select, format tool{n} with n being the tool’s index starting
// with 0.
Tool string `json:"tool"`
}
// Do sends an API request and returns an error if any.
func (cmd *ToolSelectRequest) Do(c *Client) error {
b := bytes.NewBuffer(nil)
if err := cmd.encode(b); err != nil {
return err
}
_, err := c.doJsonRequest("POST", PrinterToolApiUri, b, PrintToolErrors)
return err
}
func (cmd *ToolSelectRequest) encode(w io.Writer) error {
return json.NewEncoder(w).Encode(struct {
Command string `json:"command"`
ToolSelectRequest
}{
Command: "select",
ToolSelectRequest: *cmd,
})
}
|