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

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

import (
	"encoding/json"
	"fmt"

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


// TODO: OctoScreenSettingsRequest seems like it's practically the same as PluginManagerInfoRequest
// Need to clean up and consolidate, or add comments as to why the two different classes.

type OctoScreenSettingsRequest struct {
	Command string `json:"command"`
}

func (this *OctoScreenSettingsRequest) Do(client *Client, uiState string) (*dataModels.OctoScreenSettingsResponse, error) {
	target := fmt.Sprintf("%s?command=get_settings", PluginZBoltOctoScreenApiUri)
	bytes, err := client.doJsonRequest("GET", target, nil, ConnectionErrors, false)
	if err != nil {
		return nil, err
	}

	response := &dataModels.OctoScreenSettingsResponse{}
	if err := json.Unmarshal(bytes, response); err != nil {
		return nil, err
	}

	return response, err
}