Documentation
¶
Index ¶
- Variables
- func MapToXML(rootElement string, data map[string]interface{}) ([]byte, error)
- func XMLToMap(data []byte) (map[string]interface{}, error)
- type APIError
- type Client
- func (c *Client) Delete(path string, result interface{}) error
- func (c *Client) Get(path string, result interface{}) error
- func (c *Client) GetRaw(path string) ([]byte, error)
- func (c *Client) Patch(path string, body, result interface{}) error
- func (c *Client) Post(path string, body, result interface{}) error
- func (c *Client) Put(path string, body, result interface{}) error
- func (c *Client) PutRaw(path string, data []byte, contentType string) error
- type Requester
- type XMLBody
Constants ¶
This section is empty.
Variables ¶
var Version = "dev"
Version is set at startup from the build-time version injected by GoReleaser. Falls back to "dev" for local builds without ldflags.
Functions ¶
func MapToXML ¶
MapToXML serializes a flat (or nested) Go map to XML with the given root element. Values that are maps are recursively serialized as child elements. Slice values produce repeated elements with the same tag.
func XMLToMap ¶
XMLToMap parses an XML document into a nested map[string]interface{}. The returned map uses the root element as a top-level key, so callers get the full structure including the root element name. Repeated sibling elements with the same tag are collected into []interface{}. Text-only elements are represented as strings.
Types ¶
type Client ¶
type Client struct {
BaseURL string
// contains filtered or unexported fields
}
Client is an authenticated HTTP client for Bandwidth APIs.
func NewBasicAuthClient ¶
NewBasicAuthClient creates a Client that uses HTTP Basic Authentication.
func NewClient ¶
func NewClient(baseURL string, tm *auth.TokenManager) *Client
NewClient creates a Client that obtains Bearer tokens via the given TokenManager. Defaults to JSON mode.
func NewClientNoAuth ¶
NewClientNoAuth creates a Client without authentication (for Build registration).
func NewXMLClient ¶
func NewXMLClient(baseURL string, tm *auth.TokenManager) *Client
NewXMLClient creates a Client configured for XML serialization (Dashboard API).
func (*Client) GetRaw ¶
GetRaw performs a GET request and returns the raw response bytes. Useful for file downloads like recordings.
func (*Client) Patch ¶
Patch performs a PATCH request with body and unmarshals the response into result.
func (*Client) Post ¶
Post performs a POST request with body and unmarshals the response into result.
type Requester ¶
type Requester interface {
Get(path string, result interface{}) error
Post(path string, body, result interface{}) error
Put(path string, body, result interface{}) error
Patch(path string, body, result interface{}) error
Delete(path string, result interface{}) error
GetRaw(path string) ([]byte, error)
PutRaw(path string, data []byte, contentType string) error
}
Requester is the interface satisfied by Client. Commands accept this so tests can substitute a mock without hitting real Bandwidth APIs.