Documentation
¶
Index ¶
- Constants
- Variables
- func Bool(value bool) param.Field[bool]
- func DefaultClientOptions() []option.RequestOption
- func F[T any](value T) param.Field[T]
- func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]
- func Float(value float64) param.Field[float64]
- func Int(value int64) param.Field[int64]
- func Null[T any]() param.Field[T]
- func Raw[T any](value any) param.Field[T]
- func String(value string) param.Field[string]
- type BootPayload
- type Client
- func (c *Client) Delete(ctx context.Context, path string, params, res any, ...) error
- func (c *Client) Execute(ctx context.Context, method, path string, params, res any, ...) error
- func (c *Client) Get(ctx context.Context, path string, params, res any, ...) error
- func (c *Client) Post(ctx context.Context, path string, params, res any, ...) error
- func (c *Client) Put(ctx context.Context, path string, params, res any, ...) error
- type Error
- type ErrorPayload
- type HealthResponse
- type HealthService
- type JoinByCodeParams
- type JoinRoomParams
- type MemberListPayload
- type MemberPayload
- type MembershipResponse
- type MessageCountResponse
- type MessageDeletedPayload
- type MessageListAfterParams
- type MessageListParams
- type MessagePayload
- type MessageResponse
- type MessageService
- func (m *MessageService) Count(ctx context.Context, roomID string, opts ...option.RequestOption) (*MessageCountResponse, error)
- func (m *MessageService) List(ctx context.Context, roomID string, query MessageListParams, ...) (*MessagesResponse, error)
- func (m *MessageService) ListAfter(ctx context.Context, roomID string, query MessageListAfterParams, ...) (*MessagesResponse, error)
- func (m *MessageService) Send(ctx context.Context, roomID string, body SendMessageParams, ...) (*MessageResponse, error)
- type MessagesResponse
- type RoomCreateParams
- type RoomDeletedPayload
- type RoomResponse
- type RoomService
- func (r *RoomService) CheckMembership(ctx context.Context, id string, opts ...option.RequestOption) (*MembershipResponse, error)
- func (r *RoomService) ConnectWebSocket(ctx context.Context, roomID string, opts ...option.RequestOption) (*RoomWebSocket, error)
- func (r *RoomService) Create(ctx context.Context, body RoomCreateParams, opts ...option.RequestOption) (*RoomResponse, error)
- func (r *RoomService) Delete(ctx context.Context, id string, opts ...option.RequestOption) error
- func (r *RoomService) Get(ctx context.Context, id string, opts ...option.RequestOption) (*RoomResponse, error)
- func (r *RoomService) GetByJoinCode(ctx context.Context, body JoinByCodeParams, opts ...option.RequestOption) (*RoomResponse, error)
- func (r *RoomService) Join(ctx context.Context, id string, body JoinRoomParams, ...) (*SuccessResponse, error)
- func (r *RoomService) KickMember(ctx context.Context, roomID, userID string, opts ...option.RequestOption) (*SuccessResponse, error)
- func (r *RoomService) Leave(ctx context.Context, id string, opts ...option.RequestOption) (*SuccessResponse, error)
- type RoomWebSocket
- type SendMessageParams
- type SuccessResponse
- type UserResponse
- type WSMessage
Constants ¶
const ( MemberJoined = "member.joined" MemberLeft = "member.left" MemberList = "member.list" MessageReceived = "message.received" MessageDeleted = "message.deleted" ErrorEvent = "error" AuthenticationError = "error.auth" JoinFailed = "error.join" RateLimited = "error.rate_limited" Kicked = "error.kicked" RoomDeleted = "room.deleted" )
Variables ¶
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
func F ¶
F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.
func Int ¶
Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.
func Raw ¶
Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).
Types ¶
type BootPayload ¶
type Client ¶
type Client struct {
Options []option.RequestOption
Room *RoomService
Message *MessageService
Health *HealthService
}
func NewClient ¶
func NewClient(opts ...option.RequestOption) *Client
type ErrorPayload ¶
type HealthResponse ¶
func (*HealthResponse) UnmarshalJSON ¶
func (r *HealthResponse) UnmarshalJSON(data []byte) error
type HealthService ¶
type HealthService struct {
Options []option.RequestOption
}
func NewHealthService ¶
func NewHealthService(opts ...option.RequestOption) *HealthService
func (*HealthService) Get ¶
func (h *HealthService) Get(ctx context.Context, opts ...option.RequestOption) (*HealthResponse, error)
Get retrieves the health status of the API
type JoinByCodeParams ¶
type JoinByCodeParams struct {
JoinCode string `json:"join_code"` // 6-character join code
Username string `json:"username,omitempty"`
}
func (*JoinByCodeParams) MarshalJSON ¶
func (r *JoinByCodeParams) MarshalJSON() ([]byte, error)
type JoinRoomParams ¶
type JoinRoomParams struct {
Username string `json:"username,omitempty"`
}
func (*JoinRoomParams) MarshalJSON ¶
func (r *JoinRoomParams) MarshalJSON() ([]byte, error)
type MemberListPayload ¶
type MemberListPayload struct {
Members []MemberPayload `json:"members"`
}
type MemberPayload ¶
type MembershipResponse ¶
type MembershipResponse struct {
IsMember bool `json:"is_member"`
RoomID string `json:"room_id"`
UserID string `json:"user_id,omitempty"`
}
func (*MembershipResponse) UnmarshalJSON ¶
func (r *MembershipResponse) UnmarshalJSON(data []byte) error
type MessageCountResponse ¶
func (*MessageCountResponse) UnmarshalJSON ¶
func (r *MessageCountResponse) UnmarshalJSON(data []byte) error
type MessageDeletedPayload ¶
type MessageDeletedPayload struct {
MessageID string `json:"id"`
}
type MessageListAfterParams ¶
type MessageListParams ¶
type MessageListParams struct {
Limit int64 // Optional, defaults to 50 on server
}
type MessagePayload ¶
type MessageResponse ¶
type MessageResponse struct {
ID string `json:"id"`
RoomID string `json:"room_id"`
UserID string `json:"user_id"`
Username string `json:"username"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
}
func (*MessageResponse) UnmarshalJSON ¶
func (r *MessageResponse) UnmarshalJSON(data []byte) error
type MessageService ¶
type MessageService struct {
Options []option.RequestOption
}
func NewMessageService ¶
func NewMessageService(opts ...option.RequestOption) *MessageService
func (*MessageService) Count ¶
func (m *MessageService) Count(ctx context.Context, roomID string, opts ...option.RequestOption) (*MessageCountResponse, error)
Count retrieves the message count for a room
func (*MessageService) List ¶
func (m *MessageService) List(ctx context.Context, roomID string, query MessageListParams, opts ...option.RequestOption) (*MessagesResponse, error)
List retrieves messages from a room with optional limit
func (*MessageService) ListAfter ¶
func (m *MessageService) ListAfter(ctx context.Context, roomID string, query MessageListAfterParams, opts ...option.RequestOption) (*MessagesResponse, error)
ListAfter retrieves messages after a specific timestamp
func (*MessageService) Send ¶
func (m *MessageService) Send(ctx context.Context, roomID string, body SendMessageParams, opts ...option.RequestOption) (*MessageResponse, error)
Send sends a message to a room
type MessagesResponse ¶
type MessagesResponse struct {
Messages []MessageResponse `json:"messages"`
Count int `json:"count"`
RoomID string `json:"room_id"`
}
func (*MessagesResponse) UnmarshalJSON ¶
func (r *MessagesResponse) UnmarshalJSON(data []byte) error
type RoomCreateParams ¶
type RoomCreateParams struct {
ExpiryHours int `json:"expiry_hours"` // 1 to 168 hours (1 hour to 7 days)
}
func (*RoomCreateParams) MarshalJSON ¶
func (r *RoomCreateParams) MarshalJSON() ([]byte, error)
type RoomDeletedPayload ¶
type RoomDeletedPayload struct {
RoomID string `json:"roomid"`
}
type RoomResponse ¶
type RoomResponse struct {
ID string `json:"id"`
JoinCode string `json:"join_code"`
Owner UserResponse `json:"owner"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
Members []UserResponse `json:"members"`
CurrentUser UserResponse `json:"current_user"`
}
func (*RoomResponse) UnmarshalJSON ¶
func (r *RoomResponse) UnmarshalJSON(data []byte) error
type RoomService ¶
type RoomService struct {
Options []option.RequestOption
}
func NewRoomService ¶
func NewRoomService(opts ...option.RequestOption) *RoomService
func (*RoomService) CheckMembership ¶
func (r *RoomService) CheckMembership(ctx context.Context, id string, opts ...option.RequestOption) (*MembershipResponse, error)
CheckMembership checks if the current user is a member of a room
func (*RoomService) ConnectWebSocket ¶
func (r *RoomService) ConnectWebSocket( ctx context.Context, roomID string, opts ...option.RequestOption, ) (*RoomWebSocket, error)
func (*RoomService) Create ¶
func (r *RoomService) Create(ctx context.Context, body RoomCreateParams, opts ...option.RequestOption) (*RoomResponse, error)
Create creates a new room with specified expiry hours
func (*RoomService) Delete ¶
func (r *RoomService) Delete(ctx context.Context, id string, opts ...option.RequestOption) error
Delete deletes a room (only owner can delete)
func (*RoomService) Get ¶
func (r *RoomService) Get(ctx context.Context, id string, opts ...option.RequestOption) (*RoomResponse, error)
Get retrieves a room by ID
func (*RoomService) GetByJoinCode ¶
func (r *RoomService) GetByJoinCode(ctx context.Context, body JoinByCodeParams, opts ...option.RequestOption) (*RoomResponse, error)
GetByJoinCode retrieves a room by join code and joins the user to it
func (*RoomService) Join ¶
func (r *RoomService) Join(ctx context.Context, id string, body JoinRoomParams, opts ...option.RequestOption) (*SuccessResponse, error)
Join joins an existing room by room ID
func (*RoomService) KickMember ¶
func (r *RoomService) KickMember(ctx context.Context, roomID, userID string, opts ...option.RequestOption) (*SuccessResponse, error)
KickMember kicks a member from the room (only owner can kick)
func (*RoomService) Leave ¶
func (r *RoomService) Leave(ctx context.Context, id string, opts ...option.RequestOption) (*SuccessResponse, error)
Leave leaves a room
type RoomWebSocket ¶
type RoomWebSocket struct {
// contains filtered or unexported fields
}
func (*RoomWebSocket) Close ¶
func (ws *RoomWebSocket) Close() error
func (*RoomWebSocket) SendMessage ¶
func (ws *RoomWebSocket) SendMessage(content string) error
func (*RoomWebSocket) SetErrorHandler ¶
func (ws *RoomWebSocket) SetErrorHandler(handler func(error))
func (*RoomWebSocket) SetMessageHandler ¶
func (ws *RoomWebSocket) SetMessageHandler(handler func(WSMessage))
type SendMessageParams ¶
type SendMessageParams struct {
Content string `json:"content"` // Max 1000 characters
}
func (*SendMessageParams) MarshalJSON ¶
func (r *SendMessageParams) MarshalJSON() ([]byte, error)
type SuccessResponse ¶
type SuccessResponse struct {
Message string `json:"message"`
Data map[string]any `json:"data,omitempty"`
}
func (*SuccessResponse) UnmarshalJSON ¶
func (r *SuccessResponse) UnmarshalJSON(data []byte) error