Documentation
¶
Index ¶
- func DiscoverAPI() (string, error)
- func IsAuthError(err error) bool
- func IsNetworkError(err error) bool
- func IsNotFoundError(err error) bool
- type APIError
- type Chat
- type ChatsResponse
- type Client
- func (c *Client) GetBaseURL() string
- func (c *Client) GetChat(chatID string) (*Chat, error)
- func (c *Client) GetDesktopVersion() string
- func (c *Client) HasAuthToken() bool
- func (c *Client) ListChats() ([]Chat, error)
- func (c *Client) ListMessages(chatID string, limit int) ([]Message, error)
- func (c *Client) Ping() error
- func (c *Client) SearchMessages(query string, limit int) ([]Message, error)
- func (c *Client) SendMessage(chatID, message string) (string, error)
- func (c *Client) SetAuthToken(token string)
- type ErrorCategory
- type Message
- type MessagesResponse
- type SearchResponse
- type SendMessageRequest
- type SendMessageResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscoverAPI ¶
DiscoverAPI attempts to auto-discover the Beeper Desktop API URL
func IsAuthError ¶ added in v0.4.0
IsAuthError returns true if the error is an authentication error
func IsNetworkError ¶ added in v0.4.0
IsNetworkError returns true if the error is a network error
func IsNotFoundError ¶ added in v0.4.0
IsNotFoundError returns true if the error is a not found error
Types ¶
type APIError ¶ added in v0.4.0
type APIError struct {
// Message is the human-readable error message
Message string `json:"message"`
// Code is the error code (e.g., "auth_required", "chat_not_found")
Code string `json:"code,omitempty"`
// Category is the error category for hint generation
Category ErrorCategory `json:"category"`
// StatusCode is the HTTP status code
StatusCode int `json:"status_code,omitempty"`
// Operation is the operation that failed (e.g., "list_chats", "send_message")
Operation string `json:"operation,omitempty"`
// Hint is an actionable suggestion for resolving the error
Hint string `json:"hint,omitempty"`
// Underlying is the underlying error (not serialized to JSON)
Underlying error `json:"-"`
}
APIError represents a structured error from the API
func NewAPIError ¶ added in v0.4.0
func NewAPIError(message string, category ErrorCategory) *APIError
NewAPIError creates a new APIError with the given parameters
func NewAPIErrorFromStatus ¶ added in v0.4.0
NewAPIErrorFromStatus creates an APIError from an HTTP status code and response body
func WrapConfigError ¶ added in v0.4.0
WrapConfigError wraps a configuration error with appropriate context
func WrapNetworkError ¶ added in v0.4.0
WrapNetworkError wraps a network error with appropriate context
func (*APIError) WithOperation ¶ added in v0.4.0
WithOperation sets the operation field and returns the error
type Chat ¶
type Chat struct {
ID string `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
Network string `json:"network"`
UnreadCount int `json:"unreadCount"`
IsMuted bool `json:"isMuted"`
IsArchived bool `json:"isArchived"`
IsPinned bool `json:"isPinned"`
// Store participants as raw JSON since it's a complex nested object
Participants map[string]interface{} `json:"participants"`
}
Chat represents a Beeper chat/conversation Using a simplified structure that works with JSON unmarshaling
type ChatsResponse ¶
Chat represents a Beeper chat/conversation ChatsResponse represents the API response for listing chats
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles communication with Beeper Desktop API
func (*Client) GetBaseURL ¶ added in v0.4.0
GetBaseURL returns the base URL of the API
func (*Client) GetDesktopVersion ¶ added in v0.4.0
GetDesktopVersion returns the cached Beeper Desktop version from the last API response
func (*Client) HasAuthToken ¶ added in v0.4.0
HasAuthToken returns true if an auth token is set
func (*Client) ListMessages ¶
ListMessages retrieves messages from a chat
func (*Client) SearchMessages ¶
SearchMessages searches for messages across all chats
func (*Client) SendMessage ¶
SendMessage sends a message to a chat and returns the message ID
func (*Client) SetAuthToken ¶
SetAuthToken sets the Bearer authentication token
type ErrorCategory ¶ added in v0.4.0
type ErrorCategory string
ErrorCategory represents the type of error for categorization
const ( // CategoryAuth indicates authentication/authorization errors CategoryAuth ErrorCategory = "auth" // CategoryConfig indicates configuration errors CategoryConfig ErrorCategory = "config" // CategoryPermission indicates permission/scope errors CategoryPermission ErrorCategory = "permission" // CategoryNotFound indicates resource not found errors CategoryNotFound ErrorCategory = "not_found" // CategoryNetwork indicates network/connectivity errors CategoryNetwork ErrorCategory = "network" // CategoryValidation indicates input validation errors CategoryValidation ErrorCategory = "validation" // CategoryServer indicates server-side errors CategoryServer ErrorCategory = "server" // CategoryUnknown indicates unknown/uncategorized errors CategoryUnknown ErrorCategory = "unknown" )
type Message ¶
type Message struct {
ID string `json:"id"`
ChatID string `json:"chatID"`
Sender string `json:"senderName"`
Text string `json:"text"`
Timestamp string `json:"timestamp"` // ISO 8601 timestamp string
IsSender bool `json:"isSender"`
}
Message represents a Beeper message
type MessagesResponse ¶
MessagesResponse represents the API response for listing messages
type SearchResponse ¶
type SearchResponse struct {
Items []Message `json:"items"`
}
SearchResponse represents the API response for searching messages
type SendMessageRequest ¶
type SendMessageRequest struct {
Text string `json:"text"`
}
SendMessageRequest represents a message send request
type SendMessageResponse ¶
type SendMessageResponse struct {
ID string `json:"id"`
}
SendMessageResponse represents the API response after sending a message