api

package
v0.1.1-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func MapToXML(rootElement string, data map[string]interface{}) ([]byte, error)

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

func XMLToMap(data []byte) (map[string]interface{}, error)

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 APIError

type APIError struct {
	StatusCode int
	Body       string
}

APIError represents a non-2xx HTTP response.

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	BaseURL string
	// contains filtered or unexported fields
}

Client is an authenticated HTTP client for Bandwidth APIs.

func NewBasicAuthClient

func NewBasicAuthClient(baseURL, username, password string) *Client

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

func NewClientNoAuth(baseURL string) *Client

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) Delete

func (c *Client) Delete(path string, result interface{}) error

Delete performs a DELETE request and unmarshals the response into result.

func (*Client) Get

func (c *Client) Get(path string, result interface{}) error

Get performs a GET request and unmarshals the response into result.

func (*Client) GetRaw

func (c *Client) GetRaw(path string) ([]byte, error)

GetRaw performs a GET request and returns the raw response bytes. Useful for file downloads like recordings.

func (*Client) Patch

func (c *Client) Patch(path string, body, result interface{}) error

Patch performs a PATCH request with body and unmarshals the response into result.

func (*Client) Post

func (c *Client) Post(path string, body, result interface{}) error

Post performs a POST request with body and unmarshals the response into result.

func (*Client) Put

func (c *Client) Put(path string, body, result interface{}) error

Put performs a PUT request with body and unmarshals the response into result.

func (*Client) PutRaw

func (c *Client) PutRaw(path string, data []byte, contentType string) error

PutRaw performs a PUT request with raw binary data and a custom content type. Useful for uploading files like MMS media.

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.

type XMLBody

type XMLBody struct {
	RootElement string
	Data        map[string]interface{}
}

XMLBody wraps a request body with the XML root element name. Dashboard API commands use this when calling Post/Put on an XML client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL