Documentation
¶
Overview ¶
Package api implements the authenticated HTTP request layer for the Aura API. It handles OAuth token acquisition and refresh, URL construction, and error parsing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ClientID string
ClientSecret string
BaseURL string
APIVersion string
Timeout time.Duration
MaxRetry int
UserAgent string // e.g. "aura-go-client/v1.8.0"; defaults to "aura-go-client" if empty
}
Config holds configuration for the API service.
type Error ¶ added in v1.6.0
type Error struct {
StatusCode int `json:"status_code"`
Message string `json:"message"`
Details []ErrorDetail `json:"details,omitempty"`
}
Error represents an error response from the Aura API.
func (*Error) HasMultipleErrors ¶ added in v1.6.0
HasMultipleErrors returns true if there are multiple error details.
func (*Error) IsBadRequest ¶ added in v1.6.0
IsBadRequest returns true if the error is a 400.
func (*Error) IsNotFound ¶ added in v1.6.0
IsNotFound returns true if the error is a 404.
func (*Error) IsUnauthorized ¶ added in v1.6.0
IsUnauthorized returns true if the error is a 401.
type ErrorDetail ¶ added in v1.6.0
type ErrorDetail struct {
Message string `json:"message"`
Reason string `json:"reason,omitempty"`
Field string `json:"field,omitempty"`
}
ErrorDetail represents individual error details.
type RequestService ¶ added in v1.6.0
type RequestService interface {
Get(ctx context.Context, endpoint string) (*Response, error)
Post(ctx context.Context, endpoint string, body string) (*Response, error)
Put(ctx context.Context, endpoint string, body string) (*Response, error)
Patch(ctx context.Context, endpoint string, body string) (*Response, error)
Delete(ctx context.Context, endpoint string) (*Response, error)
}
RequestService defines the interface for making authenticated API requests. This is the middle layer that handles authentication and common API patterns.
func NewRequestService ¶ added in v1.6.0
func NewRequestService(cfg Config, logger *slog.Logger) RequestService
NewRequestService creates a new RequestService. It constructs its own HTTP transport layer internally — callers do not need to know about or create an httpclient.