Documentation
¶
Index ¶
- Constants
- func WithCursor(cursor string) requestOption
- func WithFields(resource string, fields ...string) requestOption
- func WithIncludes(include ...string) requestOption
- func WithPageSize(size int) requestOption
- type Error
- type ErrorResponse
- type PatreonClient
- func (c *PatreonClient) Exchange(authCode string) error
- func (c *PatreonClient) FetchCampaigns(opts ...requestOption) (*resources.CampaignResponse, error)
- func (c *PatreonClient) FetchMember(id string, opts ...requestOption) (*resources.MemberResponse, error)
- func (c *PatreonClient) FetchUser(opts ...requestOption) (*resources.UserResponse, error)
- func (c *PatreonClient) GetMembership() (*resources.User, *resources.Member, error)
- func (c *PatreonClient) GetToken() *oauth2.Token
- func (c *PatreonClient) SetToken(token *oauth2.Token)
- type PatreonConfig
Constants ¶
const PatreonAuthURL = "https://www.patreon.com/oauth2/authorize"
const PatreonBaseURL = "https://www.patreon.com/"
const PatreonTokenURL = "https://www.patreon.com/api/oauth2/token"
Variables ¶
This section is empty.
Functions ¶
func WithCursor ¶
func WithCursor(cursor string) requestOption
WithCursor controls cursor-based pagination. Cursor will also be extracted from navigation links for convenience.
func WithFields ¶
WithFields specifies the resource attributes you want to be returned by API.
func WithIncludes ¶
func WithIncludes(include ...string) requestOption
WithIncludes specifies the related resources you want to be returned by API.
func WithPageSize ¶
func WithPageSize(size int) requestOption
WithPageSize specifies the number of items to return.
Types ¶
type Error ¶ added in v0.0.3
type Error struct { Code int `json:"code"` CodeName string `json:"code_name"` Detail string `json:"detail"` ID string `json:"id"` Status string `json:"status"` Title string `json:"title"` }
Error describes error details.
type ErrorResponse ¶ added in v0.0.3
type ErrorResponse struct {
Errors []Error `json:"errors"`
}
ErrorResponse is a Patreon error response.
func (ErrorResponse) Error ¶ added in v0.0.3
func (e ErrorResponse) Error() string
type PatreonClient ¶
type PatreonClient struct {
// contains filtered or unexported fields
}
PatreonClient is the access point of the patreon API You need one PatreonClient per user
func NewPatreonClient ¶
func NewPatreonClient(patreonConfig *PatreonConfig) *PatreonClient
Creates a new PatreonClient from a PatreonConfig At this point the client is not usable, you need to either:
- convert an authorization code into a token with Exchange()
- set the token with SetToken()
func (*PatreonClient) Exchange ¶
func (c *PatreonClient) Exchange(authCode string) error
Converts an authorization code into a token. The authorization code is available as the code param in the redirected url
func (*PatreonClient) FetchCampaigns ¶
func (c *PatreonClient) FetchCampaigns(opts ...requestOption) (*resources.CampaignResponse, error)
func (*PatreonClient) FetchMember ¶
func (c *PatreonClient) FetchMember(id string, opts ...requestOption) (*resources.MemberResponse, error)
func (*PatreonClient) FetchUser ¶
func (c *PatreonClient) FetchUser(opts ...requestOption) (*resources.UserResponse, error)
func (*PatreonClient) GetMembership ¶ added in v0.0.4
Get the user and the membership of the user to your campaign If no error occurs:
- user will always be returned
- member will be returned if the user has a membership on your campaign otherwise it will be nil
func (*PatreonClient) GetToken ¶
func (c *PatreonClient) GetToken() *oauth2.Token
Get the token associated with this client Use case: serialisation of the token (in a session for instance)
- Note that the token has to be serialized at the end of your process cause it might be refreshed
func (*PatreonClient) SetToken ¶
func (c *PatreonClient) SetToken(token *oauth2.Token)
Set the token associated with this client Use case: creating the client from a serialized token (in a session for instance)
type PatreonConfig ¶
type PatreonConfig struct {
// contains filtered or unexported fields
}
PatreonConfig is the configuration of an API client registered here: https://www.patreon.com/portal/registration/register-clients
func NewPatreonConfig ¶
func NewPatreonConfig(clientID string, clientSecret string, redirectURL string, scopes []string) *PatreonConfig
Creates a new PatreonConfig