Documentation ¶
Index ¶
- Constants
- type APIInfo
- type APIResponse
- type Client
- func (c Client) Request(source, projectType, category string, perPage, page int) (*APIResponse, error)
- func (c *Client) RequestPlugins(category string, perPage, page int) (*APIResponse, error)
- func (c *Client) RequestThemes(category string, perPage, page int) (*APIResponse, error)
- func (c *Client) SetPluginAPISource(source string)
- func (c *Client) SetThemeAPISource(source string)
- type RepoProject
- type Requester
Constants ¶
const ( TimeFormat = "2006-01-02 3:04pm MST" TimeFormatThemes = "2006-01-02" )
* TimeFormat is the Go-style time format used for plugins. * TimeFormatThemes is the Go-style time format used for themes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIInfo ¶
type APIInfo struct { Page int `json:"page"` Pages int `json:"pages"` Results int `json:"results"` }
APIInfo contains the results from a call to the WordPress.org theme/plugin API.
type APIResponse ¶
type APIResponse struct { Info APIInfo `json:"info"` // Type is excluded from the json object as this does not come // from either the plugin or theme APIs. Type string `json:"-"` Plugins []RepoProject `json:"plugins,omitempty"` Themes []RepoProject `json:"themes,omitempty"` }
APIResponse describes a reponse from the WordPress.org theme/plugin API.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the default wporg client and implements Requester interface.
func (Client) Request ¶
func (c Client) Request(source, projectType, category string, perPage, page int) (*APIResponse, error)
Request gets information from the WordPress.org API's.
func (*Client) RequestPlugins ¶
func (c *Client) RequestPlugins(category string, perPage, page int) (*APIResponse, error)
RequestPlugins is a convenience method.
func (*Client) RequestThemes ¶
func (c *Client) RequestThemes(category string, perPage, page int) (*APIResponse, error)
RequestThemes is a convenience method.
func (*Client) SetPluginAPISource ¶
SetPluginAPISource allows to set an alternate plugins API source.
func (*Client) SetThemeAPISource ¶
SetThemeAPISource allows to set an alternate themes API source.
type RepoProject ¶
type RepoProject struct { Name string `json:"name"` Slug string `json:"slug"` Version string `json:"version"` LastUpdated string `json:"last_updated"` ShortDescription string `json:"short_description"` Description string `json:"description"` DownloadLink string `json:"download_link"` // Type is excluded from the json object as this does not come // from either the plugin or theme APIs. Type string `json:"-"` }
RepoProject describes a single item in the returned results.
func (*RepoProject) UnmarshalJSON ¶
func (rp *RepoProject) UnmarshalJSON(d []byte) error
UnmarshalJSON is a custom unmarshaller for RepoProject to deal with version passed as numbers.
type Requester ¶
type Requester interface { // Request performs the request to the WordPress.org API's. // `source` is likely to be: // - "https://api.wordpress.org/themes/info/1.1/" for themes. // - "https://api.wordpress.org/plugins/info/1.1/" for plugins. // `projectType` should be plural "themes" or "plugins". Request(source, projectType, category string, perPage, page int) (*APIResponse, error) }
Requester describes an interface for requesting projects from an API. Client below implements this interface.