client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSessionExpired

func IsSessionExpired(err error) bool

IsSessionExpired returns true if the error indicates a session expiration (errcode -14).

Types

type APIError

type APIError struct {
	Ret     int
	ErrCode int
	ErrMsg  string
}

APIError represents an error response from the iLink API.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client is the low-level iLink HTTP API client.

func NewClient

func NewClient(creds *types.Credentials, opts ...ClientOption) *Client

NewClient creates an authenticated client from credentials.

func NewUnauthenticatedClient

func NewUnauthenticatedClient(opts ...ClientOption) *Client

NewUnauthenticatedClient creates a client for the login flow (no auth token).

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL returns the API base URL.

func (*Client) BotID

func (c *Client) BotID() string

BotID returns the bot's user ID.

func (*Client) DoGet

func (c *Client) DoGet(ctx context.Context, rawURL string, result any) error

DoGet performs a GET request with auth headers.

func (*Client) Doer

func (c *Client) Doer() HTTPDoer

Doer returns the underlying HTTP doer.

func (*Client) GetConfig

func (c *Client) GetConfig(ctx context.Context, userID, contextToken string) (*types.GetConfigResponse, error)

GetConfig fetches bot config (typing_ticket) for a user.

func (*Client) GetUpdates

func (c *Client) GetUpdates(ctx context.Context, buf string) (*types.GetUpdatesResponse, error)

GetUpdates long-polls for new messages.

func (*Client) GetUploadURL

GetUploadURL gets a signed upload URL from the iLink API.

func (*Client) SendMessage

SendMessage sends a message to a user.

func (*Client) SendTyping

func (c *Client) SendTyping(ctx context.Context, userID, ticket string, status int) error

SendTyping sends a typing indicator to a user.

type ClientOption

type ClientOption func(*Client)

ClientOption configures the Client.

func WithBaseURL

func WithBaseURL(url string) ClientOption

WithBaseURL sets a custom base URL for the iLink API.

func WithHTTPDoer

func WithHTTPDoer(doer HTTPDoer) ClientOption

WithHTTPDoer sets a custom HTTP client (for testing or custom transport).

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer is the interface for making HTTP requests. Enables mocking in tests.

Jump to

Keyboard shortcuts

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