Documentation
¶
Index ¶
- Constants
- Variables
- func WithBaseURL(baseURL string) opt
- func WithHTTPClient(httpClient HTTPClient) opt
- type AppData
- type Funpay
- type FunpayAuthHandler
- type FunpayClient
- func (fp *FunpayClient) Balance() int64
- func (fp *FunpayClient) BaseURL() string
- func (fp *FunpayClient) CSRFToken() string
- func (fp *FunpayClient) Cookies() []*http.Cookie
- func (fp *FunpayClient) GoldenKey() string
- func (fp *FunpayClient) Locale() Locale
- func (fp *FunpayClient) Request(ctx context.Context, requestURL string, opts ...RequestOpt) (*http.Response, error)
- func (fp *FunpayClient) RequestHTML(ctx context.Context, requestURL string, opts ...RequestOpt) (*goquery.Document, error)
- func (fp *FunpayClient) Update(ctx context.Context) error
- func (fp *FunpayClient) UpdateLocale(ctx context.Context, locale Locale) error
- func (fp *FunpayClient) UserAgent() string
- func (fp *FunpayClient) UserID() int64
- func (fp *FunpayClient) Username() string
- type FunpayRequester
- type FunpayUpdater
- type FunpayUser
- type HTTPClient
- type Locale
- type RequestOpt
- type RequestOpts
Constants ¶
View Source
const ( Domain = "funpay.com" BaseURL = "https://" + Domain )
View Source
const ( // CookieGoldenKey is the cookie name for golden key. CookieGoldenKey = "golden_key" // HeaderUserAgent is the header name for user agent. HeaderUserAgent = "User-Agent" FormCSRFToken = "csrf_token" )
Variables ¶
View Source
var ( // ErrTooManyRequests indicates rate limiting (HTTP 429 Too Many Requests). // Returned when exceeding API request limits. ErrTooManyRequests = errors.New("too many requests") // ErrBadStatusCode indicates unexpected HTTP response status. // Returned for any non-2xx status code not covered by other errors. ErrBadStatusCode = errors.New("bad status code") )
View Source
var (
)
View Source
var ( // RequestPostHeaders contains content-type, accept and x-requested-with headers. Copy these values to your headers if needed. RequestPostHeaders = map[string]string{ "content-type": "application/x-www-form-urlencoded; charset=UTF-8", "accept": "*/*", "x-requested-with": "XMLHttpRequest", } )
Functions ¶
func WithBaseURL ¶
func WithBaseURL(baseURL string) opt
func WithHTTPClient ¶
func WithHTTPClient(httpClient HTTPClient) opt
Types ¶
type AppData ¶
type AppData struct {
CSRFToken string `json:"csrf-token"`
UserID int64 `json:"userId"`
Locale Locale `json:"locale"`
}
AppData represents the object from data-app-data attribute inside the body element.
type Funpay ¶
type Funpay interface {
FunpayUser
FunpayAuthHandler
FunpayUpdater
FunpayRequester
}
type FunpayAuthHandler ¶
type FunpayClient ¶
type FunpayClient struct {
// contains filtered or unexported fields
}
func (*FunpayClient) Balance ¶
func (fp *FunpayClient) Balance() int64
func (*FunpayClient) BaseURL ¶
func (fp *FunpayClient) BaseURL() string
func (*FunpayClient) CSRFToken ¶
func (fp *FunpayClient) CSRFToken() string
func (*FunpayClient) Cookies ¶
func (fp *FunpayClient) Cookies() []*http.Cookie
func (*FunpayClient) GoldenKey ¶
func (fp *FunpayClient) GoldenKey() string
func (*FunpayClient) Locale ¶
func (fp *FunpayClient) Locale() Locale
func (*FunpayClient) Request ¶
func (fp *FunpayClient) Request(ctx context.Context, requestURL string, opts ...RequestOpt) (*http.Response, error)
func (*FunpayClient) RequestHTML ¶
func (fp *FunpayClient) RequestHTML(ctx context.Context, requestURL string, opts ...RequestOpt) (*goquery.Document, error)
func (*FunpayClient) UpdateLocale ¶
func (fp *FunpayClient) UpdateLocale(ctx context.Context, locale Locale) error
func (*FunpayClient) UserAgent ¶
func (fp *FunpayClient) UserAgent() string
func (*FunpayClient) UserID ¶
func (fp *FunpayClient) UserID() int64
func (*FunpayClient) Username ¶
func (fp *FunpayClient) Username() string
type FunpayRequester ¶
type FunpayUpdater ¶
type FunpayUser ¶
type RequestOpt ¶
type RequestOpt func(options *RequestOpts)
RequestOpt defines a function type for modifying request options.
func RequestWithBody ¶
func RequestWithBody(body io.Reader) RequestOpt
RequestWithBody sets the request body.
func RequestWithCookies ¶
func RequestWithCookies(cookies []*http.Cookie) RequestOpt
RequestWithCookies adds additional cookies to the request. Note: Session cookies are added automatically.
func RequestWithHeaders ¶
func RequestWithHeaders(headers map[string]string) RequestOpt
RequestWithHeaders adds custom headers to the request. Headers are added in addition to default User-Agent.
func RequestWithMethod ¶
func RequestWithMethod(method string) RequestOpt
RequestWithMethod sets the HTTP method for the request. Default: GET
type RequestOpts ¶
type RequestOpts struct {
// contains filtered or unexported fields
}
RequestOpts contains configurable parameters for HTTP requests. Used internally by [Funpay.Request] to customize request behavior.
func NewRequestOpts ¶
func NewRequestOpts() *RequestOpts
NewRequestOpts creates request options with defaults:
- Method: GET
Source Files
¶
Click to show internal directories.
Click to hide internal directories.