api

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseURL     = "http://localhost:23373"
	DefaultHTTPTimeout = 30 * time.Second

	// MaxRateLimitRetries is the maximum number of retries on 429 responses.
	MaxRateLimitRetries = 3

	// RateLimitBaseDelay is the initial delay for rate limit exponential backoff.
	RateLimitBaseDelay = 1 * time.Second

	// Max5xxRetries is the maximum retries for server errors on idempotent requests.
	Max5xxRetries = 1

	// ServerErrorRetryDelay is the delay before retrying on 5xx errors.
	ServerErrorRetryDelay = 1 * time.Second

	// CircuitBreakerThreshold is consecutive 5xx errors to open circuit.
	CircuitBreakerThreshold = 5

	// CircuitBreakerResetTime is how long before trying again.
	CircuitBreakerResetTime = 30 * time.Second
)

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

func ParseError

func ParseError(resp *http.Response) error

func ParseErrorWithContext

func ParseErrorWithContext(resp *http.Response, context string) error

ParseErrorWithContext returns user-friendly error from HTTP response

func UserFriendlyError

func UserFriendlyError(err error) error

UserFriendlyError wraps an error with a user-friendly message

Types

type APIError

type APIError struct {
	StatusCode int    `json:"-"`
	Code       string `json:"code"`
	Message    string `json:"message"`
}

func (*APIError) Error

func (e *APIError) Error() string

type Account

type Account struct {
	ID      string       `json:"accountID"`
	Network string       `json:"network"`
	User    *AccountUser `json:"user,omitempty"`
}

Account represents a connected chat network

type AccountUser added in v0.1.4

type AccountUser struct {
	ID          string `json:"id"`
	FullName    string `json:"fullName,omitempty"`
	Email       string `json:"email,omitempty"`
	PhoneNumber string `json:"phoneNumber,omitempty"`
	Username    string `json:"username,omitempty"`
	DisplayText string `json:"displayText,omitempty"`
	ImgURL      string `json:"imgURL,omitempty"`
	IsSelf      bool   `json:"isSelf"`
}

AccountUser represents the user info for an account

type Chat

type Chat struct {
	ID           string           `json:"id"`
	LocalChatID  string           `json:"localChatID,omitempty"`
	AccountID    string           `json:"accountID"`
	Network      string           `json:"network,omitempty"`
	Title        string           `json:"title"`
	Type         string           `json:"type"` // "dm" or "group"
	UnreadCount  int              `json:"unreadCount"`
	IsMuted      bool             `json:"isMuted"`
	IsArchived   bool             `json:"isArchived"`
	IsPinned     bool             `json:"isPinned"`
	LastActivity time.Time        `json:"lastActivity"`
	Preview      *MessagePreview  `json:"preview,omitempty"`
	Participants *ParticipantList `json:"participants,omitempty"`
	ReminderAt   *time.Time       `json:"reminderAt,omitempty"`
}

Chat represents a conversation

type Client

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

func NewClient

func NewClient(baseURL, token string, opts ...ClientOption) *Client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body any) (*http.Response, error)

type ClientOption

type ClientOption func(*Client)

func WithDebug

func WithDebug(debug bool) ClientOption

type FocusRequest

type FocusRequest struct {
	ChatID              string `json:"chatID,omitempty"`
	MessageID           string `json:"messageID,omitempty"`
	DraftText           string `json:"draftText,omitempty"`
	DraftAttachmentPath string `json:"draftAttachmentPath,omitempty"`
}

FocusRequest for focusing Beeper window

type ListChatsResponse

type ListChatsResponse struct {
	Items   []Chat `json:"items"`
	Total   int    `json:"total"`
	HasMore bool   `json:"hasMore"`
	Cursor  string `json:"cursor,omitempty"`
}

type ListMessagesResponse

type ListMessagesResponse struct {
	Items   []Message `json:"items"`
	HasMore bool      `json:"hasMore"`
	Cursor  string    `json:"cursor,omitempty"`
}

type Message

type Message struct {
	ID        string    `json:"id"`
	ChatID    string    `json:"chatID"`
	AccountID string    `json:"accountID"`
	SenderID  string    `json:"senderID"`
	Sender    string    `json:"sender"`
	Text      string    `json:"text"`
	Timestamp time.Time `json:"timestamp"`
	IsMe      bool      `json:"isMe"`
	ReplyTo   *Message  `json:"replyTo,omitempty"`
}

Message represents a chat message

type MessagePreview

type MessagePreview struct {
	Text      string    `json:"text"`
	Sender    string    `json:"sender,omitempty"`
	Timestamp time.Time `json:"timestamp"`
}

MessagePreview is the preview shown in chat list

type Participant

type Participant struct {
	ID          string `json:"id"`
	FullName    string `json:"fullName"`
	Username    string `json:"username,omitempty"`
	PhoneNumber string `json:"phoneNumber,omitempty"`
	ImgURL      string `json:"imgURL,omitempty"`
	IsSelf      bool   `json:"isSelf"`
	IsAdmin     bool   `json:"isAdmin"`
	IsVerified  bool   `json:"isVerified"`
}

type ParticipantList

type ParticipantList struct {
	Items []Participant `json:"items"`
}

ParticipantList wraps the participants array

type ReminderRequest

type ReminderRequest struct {
	Reminder ReminderTime `json:"reminder"`
}

ReminderRequest for setting a reminder

type ReminderTime

type ReminderTime struct {
	RemindAtMs int64 `json:"remindAtMs"`
}

ReminderTime represents the time format expected by Beeper API

func NewReminderTime

func NewReminderTime(t time.Time) ReminderTime

NewReminderTime creates a ReminderTime from a time.Time

type SearchMessagesResponse

type SearchMessagesResponse struct {
	Messages []Message       `json:"messages"`
	Chats    map[string]Chat `json:"chats"`
	HasMore  bool            `json:"hasMore"`
	Cursor   string          `json:"cursor,omitempty"`
}

type SearchResponse

type SearchResponse struct {
	Chats    []Chat    `json:"chats"`
	Messages []Message `json:"messages"`
	HasMore  bool      `json:"hasMore"`
}

SearchResponse for unified search

type SendMessageRequest

type SendMessageRequest struct {
	Text             string `json:"text,omitempty"`
	ReplyToMessageID string `json:"replyToMessageID,omitempty"`
}

SendMessageRequest for sending a message

type SendMessageResponse

type SendMessageResponse struct {
	ChatID           string `json:"chatID"`
	PendingMessageID string `json:"pendingMessageID"`
}

type ValidationError

type ValidationError struct {
	Code     string   `json:"code"`
	Expected string   `json:"expected,omitempty"`
	Received string   `json:"received,omitempty"`
	Path     []string `json:"path,omitempty"`
	Message  string   `json:"message"`
}

ValidationError represents a single validation error from the API

Jump to

Keyboard shortcuts

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