Skoda Enyaq: add start/stop charger command (#1905)
This commit is contained in:
parent
a7f563d004
commit
c19f279484
4 changed files with 86 additions and 67 deletions
|
|
@ -58,7 +58,8 @@ func decodeJSON(resp *http.Response, res interface{}) error {
|
|||
return json.NewDecoder(resp.Body).Decode(&res)
|
||||
}
|
||||
|
||||
// DoJSON executes HTTP request and decodes JSON response. It returns a StatusError on response codes other than HTTP 2xx.
|
||||
// DoJSON executes HTTP request and decodes JSON response.
|
||||
// It returns a StatusError on response codes other than HTTP 2xx.
|
||||
func (r *Helper) DoJSON(req *http.Request, res interface{}) error {
|
||||
resp, err := r.Do(req)
|
||||
if err == nil {
|
||||
|
|
@ -68,12 +69,12 @@ func (r *Helper) DoJSON(req *http.Request, res interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// GetJSON executes HTTP GET request and decodes JSON response. It returns a StatusError on response codes other than HTTP 2xx.
|
||||
// GetJSON executes HTTP GET request and decodes JSON response.
|
||||
// It returns a StatusError on response codes other than HTTP 2xx.
|
||||
func (r *Helper) GetJSON(url string, res interface{}) error {
|
||||
resp, err := r.Get(url)
|
||||
req, err := New(http.MethodGet, url, nil, AcceptJSON)
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
err = decodeJSON(resp, &res)
|
||||
err = r.DoJSON(req, &res)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue