Documentation
¶
Overview ¶
Package customerapi provides an authenticated HTTP client for the XenForo Customer API.
Index ¶
- Variables
- func CheckResponse(resp *http.Response) error
- type Client
- func (c *Client) Do(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) GetAccessToken() (string, error)
- func (c *Client) GetDownloadInfo(ctx context.Context, licenseKey string, downloadID string, versionID int) (*DownloadInfo, error)
- func (c *Client) GetDownloadURL(licenseKey string, downloadID string, versionID int) string
- func (c *Client) GetJSON(ctx context.Context, path string, result any) error
- func (c *Client) GetLicenseDownloadables(ctx context.Context, licenseKey string) (*LicenseDownloadables, error)
- func (c *Client) GetLicenseVersions(ctx context.Context, licenseKey string, downloadID string) (*LicenseVersions, error)
- func (c *Client) GetLicenses(ctx context.Context) ([]License, error)
- func (c *Client) Post(ctx context.Context, path string, body io.Reader) (*http.Response, error)
- func (c *Client) PostJSON(ctx context.Context, path string, body []byte) (*http.Response, error)
- type DownloadInfo
- type DownloadInfoResponse
- type Downloadable
- type Error
- type ErrorResponse
- type License
- type LicenseDownloadables
- type LicenseExtra
- type LicenseVersions
- type LicensesResponse
- type UnixTime
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAPIError indicates the API returned an error response. ErrAPIError = errors.New("API error") // ErrAuthExpired indicates the authentication token has expired. ErrAuthExpired = errors.New("authentication expired") )
Functions ¶
func CheckResponse ¶
CheckResponse checks if an HTTP response indicates an error and returns a formatted error.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an authenticated HTTP client for the XenForo Customer API.
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, method, path string, body io.Reader) (*http.Response, error)
Do sends an HTTP request and returns the response.
func (*Client) GetAccessToken ¶
GetAccessToken retrieves the current access token.
func (*Client) GetDownloadInfo ¶
func (c *Client) GetDownloadInfo(ctx context.Context, licenseKey string, downloadID string, versionID int) (*DownloadInfo, error)
GetDownloadInfo retrieves download information for a specific version.
func (*Client) GetDownloadURL ¶
GetDownloadURL returns the URL to download a specific version.
func (*Client) GetLicenseDownloadables ¶
func (c *Client) GetLicenseDownloadables(ctx context.Context, licenseKey string) (*LicenseDownloadables, error)
GetLicenseDownloadables retrieves the downloadable products for a license.
func (*Client) GetLicenseVersions ¶
func (c *Client) GetLicenseVersions(ctx context.Context, licenseKey string, downloadID string) (*LicenseVersions, error)
GetLicenseVersions retrieves the available versions for a product.
func (*Client) GetLicenses ¶
GetLicenses retrieves all licenses for the authenticated user.
type DownloadInfo ¶
type DownloadInfo struct {
LicenseKey string `json:"license_key"`
DownloadID string `json:"download_id"`
VersionID int `json:"version_id"`
VersionString string `json:"version_string"`
Filename string `json:"filename"`
DownloadURL string `json:"download_url"`
}
DownloadInfo represents information about a downloadable file.
type DownloadInfoResponse ¶
type DownloadInfoResponse struct {
Download DownloadInfo `json:"download"`
}
DownloadInfoResponse is the API response for download information.
type Downloadable ¶
Downloadable represents a downloadable product associated with a license.
type Error ¶
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
Params map[string]any `json:"params,omitempty"`
}
Error represents an error response from the API.
type ErrorResponse ¶
type ErrorResponse struct {
Errors []Error `json:"errors"`
}
ErrorResponse represents the error response structure from XenForo API.
func ParseError ¶
func ParseError(body []byte) (*ErrorResponse, error)
ParseError parses an API error response.
type License ¶
type License struct {
LicenseID int `json:"license_id"`
LicenseKey string `json:"license_key"`
ProductID string `json:"product_id"`
ProductTitle string `json:"product_title"`
IsValid bool `json:"is_valid"`
IsActive bool `json:"is_active"`
StartDate UnixTime `json:"start_date"`
ExpirationDate UnixTime `json:"expiration_date"`
SiteURL string `json:"site_url,omitempty"`
SiteTitle string `json:"site_title,omitempty"`
CanDownload bool `json:"can_download"`
Extras []LicenseExtra `json:"extras,omitempty"`
}
License represents a XenForo customer license.
type LicenseDownloadables ¶
type LicenseDownloadables struct {
LicenseKey string `json:"license_key"`
Downloadables []Downloadable `json:"downloadables"`
}
LicenseDownloadables represents the downloadables available for a license.
type LicenseExtra ¶
type LicenseExtra struct {
ExtraID string `json:"extra_id"`
Name string `json:"name"`
StartDate UnixTime `json:"start_date"`
IsDownloadable bool `json:"is_downloadable"`
}
LicenseExtra represents an extra (add-on product) associated with a license.
type LicenseVersions ¶
type LicenseVersions struct {
LicenseKey string `json:"license_key"`
DownloadID string `json:"download_id"`
Versions []Version `json:"versions"`
}
LicenseVersions represents the versions available for a license/download.
type LicensesResponse ¶
type LicensesResponse struct {
Licenses []License `json:"licenses"`
}
LicensesResponse represents the API response for listing licenses.
type UnixTime ¶
UnixTime is a time.Time that unmarshals from Unix timestamps.
func (*UnixTime) UnmarshalJSON ¶
UnmarshalJSON unmarshals a Unix timestamp or RFC3339 string into a UnixTime.