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

github.com/Z-Bolt/OctoScreen.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'octoprintApis/BedStateRequest.go')
-rwxr-xr-xoctoprintApis/BedStateRequest.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/octoprintApis/BedStateRequest.go b/octoprintApis/BedStateRequest.go
new file mode 100755
index 0000000..893e9ad
--- /dev/null
+++ b/octoprintApis/BedStateRequest.go
@@ -0,0 +1,43 @@
+package octoprintApis
+
+import (
+ // "bytes"
+ "encoding/json"
+ "fmt"
+ // "io"
+ // "strings"
+
+ "github.com/Z-Bolt/OctoScreen/octoprintApis/dataModels"
+)
+
+
+// BedStateRequest retrieves the current temperature data (actual, target and
+// offset) plus optionally a (limited) history (actual, target, timestamp) for
+// the printer’s heated bed.
+//
+// It’s also possible to retrieve the temperature history by supplying the
+// history query parameter set to true. The amount of returned history data
+// points can be limited using the limit query parameter.
+type BedStateRequest struct {
+ // History if true retrieve the temperature history.
+ IncludeHistory bool
+
+ // Limit limtis amount of returned history data points.
+ Limit int
+}
+
+// Do sends an API request and returns the API response.
+func (cmd *BedStateRequest) Do(c *Client) (*dataModels.TemperatureStateResponse, error) {
+ uri := fmt.Sprintf("%s?history=%t&limit=%d", PrinterBedApiUri, cmd.IncludeHistory, cmd.Limit)
+ b, err := c.doJsonRequest("GET", uri, nil, PrintBedErrors)
+ if err != nil {
+ return nil, err
+ }
+
+ r := &dataModels.TemperatureStateResponse{}
+ if err := json.Unmarshal(b, &r); err != nil {
+ return nil, err
+ }
+
+ return r, err
+}