func ValidateURL(u string) error {
	_, err := url.Parse(u)
	if err != nil {
		return err
	}
	return nil
}
ValidateURL validates if the given URL is valid for the SensorBee API server.
package client
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"net/url"
	"path"
	"strings"
)
type Requester struct {
	cli    *http.Client
	url    string
	prefix string
}
func NewRequester(url, version string) (*Requester, error) {
	return NewRequesterWithClient(url, version, http.DefaultClient)
}
func NewRequesterWithClient(url, version string, cli *http.Client) (*Requester, error) {
	if err := ValidateURL(url); err != nil {
		return nil, err
	}
	if err := ValidateAPIVersion(version); err != nil {
		return nil, err
	}
	if !strings.HasSuffix(url, "/") {
		url += "/"
	}
	return &Requester{
		cli:    cli,
		url:    url,
		prefix: "api/" + version,
	}, nil
}
func (r *Requester) Do(method Method, path string, body interface{}) (*Response, error) {
	req, err := r.NewRequest(method, path, body)
	if err != nil {
		return nil, err
	}
	return r.DoWithRequest(req)
}
func (r *Requester) NewRequest(method Method, apiPath string, bodyJSON interface{}) (*http.Request, error) {
	var body io.Reader  
	if bodyJSON == nil {
		body = nil
	} else {
		bd, err := json.Marshal(bodyJSON)
		if err != nil {
			return nil, err
		}
		body = bytes.NewReader(bd)
	}
	req, err := http.NewRequest(method.String(), r.url+path.Join(r.prefix, apiPath), body)
	if err != nil {
		return nil, err
	}
	req.Header.Add("Content-Type", "application/json")
	return req, nil
}
func (r *Requester) DoWithRequest(req *http.Request) (*Response, error) {
	res, err := r.cli.Do(req)
	if err != nil {
		return nil, err
	}
	return &Response{
		Raw: res,
	}, nil
}