Documentation
¶
Overview ¶
Package tools contains various tools to make it easier to use the Tado API
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errors ¶ added in v2.0.1
func Errors(errs *tado.ErrorResponse) error
Errors converts the errors in ErrorResponse to a Go error
func Errors422 ¶ added in v2.0.1
func Errors422(errs *tado.ErrorResponse422) error
Errors422 converts the errors in ErrorResponse422 to a Go error
func GetHomes ¶
func GetHomes(ctx context.Context, client TadoClient) ([]tado.HomeBase, error)
GetHomes returns the list of Home ID's that are registered under the user's account.
func HandleErrors ¶ added in v2.3.1
HandleErrors converts an HTTP error received from the server to a generic Go error. resp should be the http.Response received, and tadoErrors a map of received Error objects by HTTP StatusCode, for example:
me, err := client.GetMeWithResponse(ctx) if err != nil { return nil, fmt.Errorf("GetMeWithResponse: %w", err) } if me.StatusCode() != http.StatusOK { return nil, HandleErrors(me.HTTPResponse, map[int]any{ http.StatusUnauthorized: me.JSON401, }) }
Types ¶
type TadoClient ¶ added in v2.0.1
Click to show internal directories.
Click to hide internal directories.