api

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout is the default HTTP client timeout
	DefaultTimeout = 30 * time.Second
	// DefaultMaxRetries is the default number of retry attempts for API calls
	DefaultMaxRetries = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code       int    `json:"code"`
	Message    string `json:"msg"`
	ReasonCode string `json:"reasonCode,omitempty"`
	Reason     string `json:"reason,omitempty"`
}

func NewAPIError

func NewAPIError(code int, message string) *APIError

func NewAPIErrorWithReason

func NewAPIErrorWithReason(code int, message, reasonCode, reason string) *APIError

func (*APIError) Error

func (e *APIError) Error() string

type HTTPError added in v0.9.5

type HTTPError struct {
	StatusCode int
	Status     string
}

HTTPError represents an HTTP-level error (non-200 status code)

func NewHTTPError added in v0.9.5

func NewHTTPError(statusCode int, status string) *HTTPError

func (*HTTPError) Error added in v0.9.5

func (e *HTTPError) Error() string

func (*HTTPError) IsRateLimitError added in v0.9.5

func (e *HTTPError) IsRateLimitError() bool

IsRateLimitError returns true if this is an HTTP 429 rate limit error

type JSONRPCClient

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

func NewJSONRPCClient

func NewJSONRPCClient(client *http.Client, session *Session) *JSONRPCClient

func (*JSONRPCClient) Call

func (c *JSONRPCClient) Call(ctx context.Context, method string, params interface{}) (map[string]interface{}, error)

func (*JSONRPCClient) SetEndpoint

func (c *JSONRPCClient) SetEndpoint(endpoint string)

func (*JSONRPCClient) SetHTTPClient

func (c *JSONRPCClient) SetHTTPClient(client *http.Client)

type JSONRPCRequest

type JSONRPCRequest struct {
	Method string      `json:"method"`
	Params interface{} `json:"params"`
	ID     int         `json:"id"`
}

type JSONRPCResponse

type JSONRPCResponse struct {
	Result interface{} `json:"result"`
	Error  interface{} `json:"error"`
	ID     int         `json:"id"`
}

type Session

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

func NewSession

func NewSession() *Session

func (*Session) Clear

func (s *Session) Clear()

func (*Session) GetCookies

func (s *Session) GetCookies() []*http.Cookie

func (*Session) StoreCookies

func (s *Session) StoreCookies(cookies []*http.Cookie)

type Transport

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

func NewTransport

func NewTransport() (*Transport, error)

func (*Transport) Call

func (t *Transport) Call(ctx context.Context, method string, params map[string]interface{}) (map[string]interface{}, error)

func (*Transport) Login

func (t *Transport) Login(ctx context.Context, username, password string) error

func (*Transport) Logout

func (t *Transport) Logout(ctx context.Context) error

func (*Transport) SetEndpoint

func (t *Transport) SetEndpoint(endpoint string)

func (*Transport) SetHTTPClient

func (t *Transport) SetHTTPClient(client *http.Client)

func (*Transport) SetTimeout

func (t *Transport) SetTimeout(timeout time.Duration)

func (*Transport) SetUserAgent

func (t *Transport) SetUserAgent(userAgent string)

type XMLRPCClient

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

func NewXMLRPCClient

func NewXMLRPCClient(client *http.Client, session *Session) *XMLRPCClient

func (*XMLRPCClient) Call

func (c *XMLRPCClient) Call(ctx context.Context, method string, params map[string]interface{}) (map[string]interface{}, error)

func (*XMLRPCClient) SetEndpoint

func (c *XMLRPCClient) SetEndpoint(endpoint string)

func (*XMLRPCClient) SetHTTPClient

func (c *XMLRPCClient) SetHTTPClient(client *http.Client)

type XMLRPCMember

type XMLRPCMember struct {
	Name  string      `xml:"name"`
	Value XMLRPCValue `xml:"value"`
}

type XMLRPCMethodCall

type XMLRPCMethodCall struct {
	XMLName xml.Name     `xml:"methodCall"`
	Method  string       `xml:"methodName"`
	Params  XMLRPCParams `xml:"params"`
}

type XMLRPCMethodResponse

type XMLRPCMethodResponse struct {
	XMLName xml.Name     `xml:"methodResponse"`
	Params  XMLRPCParams `xml:"params"`
}

type XMLRPCParam

type XMLRPCParam struct {
	Value XMLRPCValue `xml:"value"`
}

type XMLRPCParams

type XMLRPCParams struct {
	Param []XMLRPCParam `xml:"param"`
}

type XMLRPCStruct

type XMLRPCStruct struct {
	Member []XMLRPCMember `xml:"member"`
}

type XMLRPCValue

type XMLRPCValue struct {
	Struct XMLRPCStruct `xml:"struct,omitempty"`
	String string       `xml:"string,omitempty"`
	Int    int          `xml:"int,omitempty"`
	Bool   bool         `xml:"boolean,omitempty"`
}

Jump to

Keyboard shortcuts

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