api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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:"id"`
	NetworkName     string `json:"networkName"`
	NetworkIcon     string `json:"networkIcon,omitempty"`
	ProfileName     string `json:"profileName,omitempty"`
	ProfileEmail    string `json:"profileEmail,omitempty"`
	ProfilePhone    string `json:"profilePhone,omitempty"`
	ProfileUsername string `json:"profileUsername,omitempty"`
}

Account represents a connected chat network

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 GetAccountsResponse

type GetAccountsResponse struct {
	Accounts []Account `json:"accounts"`
}

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 {
	MessageID string `json:"messageID"`
	Deeplink  string `json:"deeplink"`
}

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