Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BedTargetRequest.go « octoprintApis - github.com/Z-Bolt/OctoScreen.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 64936ea9df09794228cae5abe825fe93d3674d49 (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
package octoprintApis

import (
	"bytes"
	"encoding/json"
	// "fmt"
	"io"
	// "strings"

	// "github.com/Z-Bolt/OctoScreen/octoprintApis/dataModels"
)


// BedTargetRequest sets the given target temperature on the printer’s bed.
type BedTargetRequest struct {
	// Target temperature to set.
	Target float64 `json:"target"`
}

// Do sends an API request and returns an error if any.
func (cmd *BedTargetRequest) Do(c *Client) error {
	b := bytes.NewBuffer(nil)
	if err := cmd.encode(b); err != nil {
		return err
	}

	_, err := c.doJsonRequest("POST", PrinterBedApiUri, b, PrintBedErrors)
	return err
}

func (cmd *BedTargetRequest) encode(w io.Writer) error {
	return json.NewEncoder(w).Encode(struct {
		Command string `json:"command"`
		BedTargetRequest
	}{
		Command:          "target",
		BedTargetRequest: *cmd,
	})
}