Documentation
¶
Index ¶
- func ParseResponse(resp *http.Response, v interface{}) error
- type Client
- func (c *Client) GetAccessToken() string
- func (c *Client) GetHTTPClient() *http.Client
- func (c *Client) GetLogger() Logger
- func (c *Client) GetPlugin(name string) (Plugin, bool)
- func (c *Client) RegisterPlugin(plugin Plugin)
- func (c *Client) Request(method, path string, params url.Values, body interface{}) (*http.Response, error)
- func (c *Client) RequestMultipart(path string, fields []MultipartField, files []MultipartFile) (*http.Response, error)
- func (c *Client) RequestWithContext(ctx context.Context, method, path string, params url.Values, body interface{}) (*http.Response, error)
- func (c *Client) RequestWithRetry(ctx context.Context, method, path string, params url.Values, body interface{}) (*http.Response, error)
- type Config
- type Logger
- type MultipartField
- type MultipartFile
- type Page
- type Plugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseResponse ¶
ParseResponse parses an HTTP response into the given interface
Types ¶
type Client ¶
type Client struct {
// Base URL for API requests
BaseURL *url.URL
// Configuration for the client
Config *Config
// contains filtered or unexported fields
}
Client is the main Webex client struct
func NewClient ¶
NewClient creates a new Webex client with the given access token and optional configuration
func (*Client) GetAccessToken ¶
GetAccessToken returns the access token used for API authentication
func (*Client) GetHTTPClient ¶
GetHTTPClient returns the HTTP client used for API requests
func (*Client) RegisterPlugin ¶
RegisterPlugin registers a plugin with the client
func (*Client) Request ¶
func (c *Client) Request(method, path string, params url.Values, body interface{}) (*http.Response, error)
Request performs an HTTP request to the Webex API. The caller is responsible for closing the response body when done.
func (*Client) RequestMultipart ¶
func (c *Client) RequestMultipart(path string, fields []MultipartField, files []MultipartFile) (*http.Response, error)
RequestMultipart performs a multipart/form-data POST request to the Webex API. This is required for local file uploads (e.g., sending messages with attachments). The caller is responsible for closing the response body when done.
func (*Client) RequestWithContext ¶
func (c *Client) RequestWithContext(ctx context.Context, method, path string, params url.Values, body interface{}) (*http.Response, error)
RequestWithContext performs an HTTP request to the Webex API with the given context. The context can be used for per-request timeouts and cancellation. The caller is responsible for closing the response body when done.
func (*Client) RequestWithRetry ¶
func (c *Client) RequestWithRetry(ctx context.Context, method, path string, params url.Values, body interface{}) (*http.Response, error)
RequestWithRetry performs an HTTP request with automatic retry for transient errors. It retries on HTTP 429 (Too Many Requests, respecting Retry-After header) and transient server errors (502, 503, 504) using exponential backoff. The caller is responsible for closing the response body when done.
type Config ¶
type Config struct {
// BaseURL is the base URL of the Webex API
BaseURL string
// Timeout for API requests
Timeout time.Duration
// Default headers to include in API requests
DefaultHeaders map[string]string
// Custom HTTP client to use instead of the default one
// If nil, a default client will be created with the specified Timeout
HttpClient *http.Client
// MaxRetries is the maximum number of retries for transient errors (429, 502, 503, 504).
// Set to 0 to disable retries. Default: 3.
MaxRetries int
// RetryBaseDelay is the initial delay between retries. Default: 1s.
// Subsequent retries use exponential backoff (delay * 2^attempt).
RetryBaseDelay time.Duration
// Logger is the logger for SDK operations. If nil, the standard library's
// default logger (log.Default()) is used.
Logger Logger
}
Config holds the configuration for the Webex client
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default configuration for the Webex client
type Logger ¶
Logger is the interface for SDK logging. Any logger that implements Printf (such as the standard library's *log.Logger) can be used.
type MultipartField ¶
MultipartField represents a text field in a multipart request.
type MultipartFile ¶
type MultipartFile struct {
FieldName string // Form field name (e.g., "files")
FileName string // Original filename (e.g., "report.pdf")
Content []byte // Raw file bytes
}
MultipartFile represents a file to upload in a multipart request.
type Page ¶
type Page struct {
Items []json.RawMessage `json:"items"`
NextPage string `json:"nextPage,omitempty"`
PrevPage string `json:"prevPage,omitempty"`
HasNext bool `json:"-"`
HasPrev bool `json:"-"`
Client *Client `json:"-"`
Resource string `json:"-"`
}
Page represents a paginated response from the Webex API