Documentation
¶
Overview ¶
Package patreon is a Go client library for accessing the Patreon API.
Index ¶
- Constants
- type Address
- type AddressAttributes
- type Benefit
- type BenefitAttributes
- type Campaign
- type CampaignAttributes
- type Client
- func (c *Client) Client() *http.Client
- func (c *Client) GetAllMembersByCampaignID(id string, opts ...RequestOpt) ([]*Member, error)
- func (c *Client) GetCampaignByID(id string, opts ...RequestOpt) (*Campaign, error)
- func (c *Client) GetCampaigns(opts ...RequestOpt) ([]*Campaign, error)
- func (c *Client) GetIdentity(opts ...RequestOpt) (*User, error)
- func (c *Client) GetMemberByID(id string, opts ...RequestOpt) (*Member, error)
- func (c *Client) GetMembersByCampaignID(id string, opts ...RequestOpt) ([]*Member, error)
- type DeliverableAttributes
- type Deliverables
- type Error
- type ErrorResponse
- type Goal
- type GoalAttributes
- type Media
- type MediaAttributes
- type Member
- type MemberAttributes
- type OAuthClient
- type OAuthClientAttributes
- type RequestOpt
- type SocialConnection
- type SocialConnections
- type Tier
- type TierAttributes
- type User
- type UserAttributes
- type Webhook
- type WebhookAttributes
Constants ¶
const BaseURL = "https://www.patreon.com"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { *AddressAttributes ID string // The user this address belongs to. User *User // The campaigns that have access to the address. Campaigns []*Campaign }
Address represents a patron's shipping address.
type AddressAttributes ¶
type AddressAttributes struct { // Full recipient name. Can be null. Addressee string `json:"addressee"` // First line of street address. Can be null. Line1 string `json:"line_1"` // Second line of street address. Can be null. Line2 string `json:"line_2"` // Postal or zip code. Can be null. PostalCode string `json:"postal_code"` // Patron's city City string `json:"city"` // State or province name. Can be null State string `json:"state"` // Patron's country Country string `json:"country"` // Telephone number. Specified for non-US addresses. Can be null. PhoneNumber string `json:"phone_number"` // Datetime address was first created. CreatedAt time.Time `json:"created_at"` }
AddressAttributes represent patron's shipping address attributes
type Benefit ¶
type Benefit struct { *BenefitAttributes ID string // The Tiers the benefit has been added to. Tiers []*Tier // The Deliverables that have been generated by the Benefit Deliverables []*Deliverables // The Campaign the benefit belongs to Campaign *Campaign }
Benefit represents a benefit added to the campaign, which can be added to a tier to be delivered to the patron.
type BenefitAttributes ¶
type BenefitAttributes struct { // Benefit display title Title string `json:"title"` // Benefit display description. Can be null. Description string `json:"description"` // Type of benefit, such as custom for creator-defined benefits. Can be null. BenefitType string `json:"benefit_type"` // A rule type designation, such as eom_monthly or one_time_immediate. Can be null. RuleType string `json:"rule_type"` // Datetime this benefit was created CreatedAt time.Time `json:"created_at"` // Number of deliverables for this benefit that have been marked complete DeliveredDeliverablesCount int `json:"delivered_deliverables_count"` // Number of deliverables for this benefit that are due, for all dates. NotDeliveredDeliverablesCount int `json:"not_delivered_deliverables_count"` // Number of deliverables for this benefit that are due today specifically. DeliverablesDueTodayCount int `json:"deliverables_due_today_count"` // The next due date (after EOD today) for this benefit. Can be null. NextDeliverableDueDate time.Time `json:"next_deliverable_due_date"` // Number of tiers containing this benefit. TiersCount int `json:"tiers_count"` // true if this benefit has been deleted. IsDeleted bool `json:"is_deleted"` // true if this benefit is ready to be shown to patrons. IsPublished bool `json:"is_published"` // The third-party external ID this reward is associated with, if any. Can be null. AppExternalId string `json:"app_external_id"` // Any metadata the third-party app included with this benefit on creation. Can be null. AppMeta interface{} `json:"app_meta"` }
BenefitAttributes represent a benefit attributes added to the campaign.
type Campaign ¶
type Campaign struct { *CampaignAttributes ID string // The campaign's tiers. Tiers []*Tier // The campaign owner. Creator *User // The campaign's benefits. Benefits []*Benefit // The campaign's goals. Goals []*Goal }
Campaign represents the creator's page, and the top-level object for accessing lists of members, tiers, etc.
type CampaignAttributes ¶
type CampaignAttributes struct { // The creator's summary of their campaign. Can be null. Summary string `json:"summary"` // The type of content the creator is creating, as in "vanity is creating creation_name". Can be null. CreationName string `json:"creation_name"` // The thing which patrons are paying per, as in "vanity is making $1000 per pay_per_name". Can be null. PayPerName string `json:"pay_per_name"` // Pithy one-liner for this campaign, displayed on the creator page. Can be null. OneLiner string `json:"one_liner"` // Can be null. MainVideoEmbed string `json:"main_video_embed"` // Can be null. MainVideoURL string `json:"main_video_url"` // Banner image URL for the campaign. ImageURL string `json:"image_url"` // URL for the campaign's profile image. ImageSmallURL string `json:"image_small_url"` // URL for the video shown to patrons after they pledge to this campaign. Can be null. ThanksVideoURL string `json:"thanks_video_url"` // Can be null. ThanksEmbed string `json:"thanks_embed"` // Thank you message shown to patrons after they pledge to this campaign. Can be null. ThanksMsg string `json:"thanks_msg"` // true if the campaign charges per month, false if the campaign charges per-post. IsMonthly bool `json:"is_monthly"` // Whether this user has opted-in to rss feeds. HasRSS bool `json:"has_rss"` // Whether or not the creator has sent a one-time rss notification email. HasSentRSSNotify bool `json:"has_sent_rss_notify"` // The title of the campaigns rss feed. RSSFeedTitle string `json:"rss_feed_title"` // The url for the rss album artwork. Can be null. RSSArtworkURL string `json:"rss_artwork_url"` // true if the creator has marked the campaign as containing nsfw content. IsNSFW bool `json:"is_nsfw"` // true if the campaign charges upfront, false otherwise. Can be null. IsChargedImmediately bool `json:"is_charged_immediately"` // Datetime that the creator first began the campaign creation process. CreatedAt time.Time `json:"created_at"` // Datetime that the creator most recently published (made publicly visible) the campaign. Can be null. PublishedAt time.Time `json:"published_at"` // Relative (to patreon.com) URL for the pledge checkout flow for this campaign. PledgeURL string `json:"pledge_url"` // Number of patrons pledging to this creator. PatronCount int `json:"patron_count"` // The ID of the external discord server that is linked to this campaign. Can be null. DiscordServerID string `json:"discord_server_id"` // The ID of the Google Analytics tracker that the creator wants metrics to be sent to. Can be null. GoogleAnalyticsID string `json:"google_analytics_id"` // The visibility of the campaign's total earnings. One of private, public, patrons_only. EarningsVisibility string `json:"earnings_visibility"` }
CampaignAttributes represents the creator's page attributes.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages communication with Patreon API.
func NewClient ¶
NewClient returns a new Patreon API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).
func (*Client) GetAllMembersByCampaignID ¶
func (c *Client) GetAllMembersByCampaignID(id string, opts ...RequestOpt) ([]*Member, error)
GetAllMembersByCampaignID is like GetMembersByCampaignID but gets all members through pagination
func (*Client) GetCampaignByID ¶
func (c *Client) GetCampaignByID(id string, opts ...RequestOpt) (*Campaign, error)
GetCampaignByID returns information about a single Campaign, fetched by campaign ID Requires the campaigns scope. Top-level includes: tiers, creator, benefits, goals. https://docs.patreon.com/#get-api-oauth2-v2-campaigns-campaign_id
func (*Client) GetCampaigns ¶
func (c *Client) GetCampaigns(opts ...RequestOpt) ([]*Campaign, error)
GetCampaigns returns a list of GetCampaigns owned by the authorized user. Requires the campaigns scope. Top-level includes: tiers, creator, benefits, goals. See https://docs.patreon.com/#get-api-oauth2-v2-campaigns
func (*Client) GetIdentity ¶
func (c *Client) GetIdentity(opts ...RequestOpt) (*User, error)
GetIdentity fetches the User resource. Top-level includes: memberships, campaign. This is the endpoint for accessing information about the current User with reference to the oauth token. With the basic scope of identity, you will receive the user’s public profile information. If you have the identity[email] scope, you will also get the user’s email address. You will not receive email address without that scope. See https://docs.patreon.com/#get-api-oauth2-v2-identity
func (*Client) GetMemberByID ¶
func (c *Client) GetMemberByID(id string, opts ...RequestOpt) (*Member, error)
GetMemberByID gets a particular member by id. Requires the campaigns.members scope. Top-level includes: address (requires campaign.members.address scope), campaign, currently_entitled_tiers, user. We recommend using currently_entitled_tiers to see exactly what a member is entitled to, either as an include on the members list or on the member get. See https://docs.patreon.com/#get-api-oauth2-v2-members-id
func (*Client) GetMembersByCampaignID ¶
func (c *Client) GetMembersByCampaignID(id string, opts ...RequestOpt) ([]*Member, error)
GetMembersByCampaignID gets the Members for a given Campaign by id. Requires the campaigns.members scope. Top-level includes: address (requires campaign.members.address scope), campaign, currently_entitled_tiers, user. We recommend using currently_entitled_tiers to see exactly what a Member is entitled to, either as an include on the members list or on the member get. See https://docs.patreon.com/#get-api-oauth2-v2-campaigns-campaign_id-members
type DeliverableAttributes ¶
type DeliverableAttributes struct { // When the creator marked the deliverable as completed or fulfilled to the patron. Can be null. CreatedAt time.Time `json:"created_at"` // One of delivered, not_delivered, wont_deliver. DeliveryStatus string `json:"delivery_status"` // When the deliverable is due to the patron. DueAt time.Time `json:"due_at"` }
DeliverableAttributes represents deliverable attributes.
type Deliverables ¶
type Deliverables struct { *DeliverableAttributes ID string // The Campaign the Deliverables were generated for. Campaign *Campaign // The Benefit the Deliverables were generated for. Benefit *Benefit // The member who has been granted the deliverable. Member *Member // The user who has been granted the deliverable. This user is the same as the member user. User *User }
Deliverables represents the record of whether or not a patron has been delivered the benefitthey are owed because of their member tier.
type Error ¶
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 ¶
type ErrorResponse struct {
Errors []Error `json:"errors"`
}
ErrorResponse is a Patreon error response.
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type Goal ¶
type Goal struct { *GoalAttributes ID string // The campaign trying to reach the goal Campaign *Campaign }
Goal represents a funding goal in USD set by a creator on a campaign.
type GoalAttributes ¶
type GoalAttributes struct { // Goal amount in USD cents. AmountCents int `json:"amount_cents"` // Goal title. Title string `json:"title"` // Goal description. Can be null. Description string `json:"description"` // When the goal was created for the campaign. CreatedAt time.Time `json:"created_at"` // When the campaign reached the goal. Can be null. ReachedAt time.Time `json:"reached_at"` // Equal to (pledge_sum/goal amount)*100, helpful when a creator CompletedPercentage int `json:"completed_percentage"` }
GoalAttributes represents a funding goal in USD set by a creator on a campaign.
type Media ¶
type Media struct { *MediaAttributes ID string }
Media represents a file uploaded to patreon.com, usually an image.
type MediaAttributes ¶
type MediaAttributes struct { // File name. FileName string `json:"file_name"` // Size of file in bytes. SizeBytes int `json:"size_bytes"` // Mimetype of uploaded file, eg: "application/jpeg". Mimetype string `json:"mimetype"` // Upload availability state of the file. State string `json:"state"` // Type of the resource that owns the file. OwnerType string `json:"owner_type"` // Ownership id (See also owner_type). OwnerID string `json:"owner_id"` // Ownership relationship type for multi-relationship medias. OwnerRelationship string `json:"owner_relationship"` // When the upload URL expires. UploadExpiresAt time.Time `json:"upload_expires_at"` // The URL to perform a POST request to in order to upload the media file. UploadURL string `json:"upload_url"` // All the parameters that have to be added to the upload form request. UploadParameters interface{} `json:"upload_parameters"` // The URL to download this media. Valid for 24 hours. DownloadURL string `json:"download_url"` // When the file was created. CreatedAt time.Time `json:"created_at"` // Metadata related to the file. Can be null. Metadata interface{} `json:"metadata"` }
MediaAttributes represents a file's attributes uploaded to patreon.com.
type Member ¶
type Member struct { *MemberAttributes ID string // The member's shipping address that they entered for the campaign.Requires the campaign.members.address scope. Address *Address // The campaign that the membership is for. Campaign *Campaign // The tiers that the member is entitled to. This includes a current pledge, // or payment that covers the current payment period. CurrentlyEntitledTiers []*Tier // The user who is pledging to the campaign. User *User }
Member represents the record of a user's membership to a campaign. Remains consistent across months of pledging.
type MemberAttributes ¶
type MemberAttributes struct { // One of active_patron, declined_patron, former_patron. Can be null. PatronStatus string `json:"patron_status"` // The user is not a pledging patron but has subscribed to updates about public posts. IsFollower bool `json:"is_follower"` // Full name of the member user. FullName string `json:"full_name"` // The member's email address. Requires the campaigns.members[email] scope. Email string `json:"email"` // Datetime of beginning of most recent pledge chainfrom this member to the campaign. // Pledge updates do not change this value. Can be null. PledgeRelationshipStart time.Time `json:"pledge_relationship_start"` // The total amount that the member has ever paid to the campaign. 0 if never paid. LifetimeSupportCents int `json:"lifetime_support_cents"` // The amount in cents that the member is entitled to.This includes a current pledge, or // payment that covers the current payment period. CurrentlyEntitledAmountCents int `json:"currently_entitled_amount_cents"` // Datetime of last attempted charge. null if never charged. Can be null. LastChargeDate time.Time `json:"last_charge_date"` // The result of the last attempted charge. The only successful status is Paid. // null if never charged. // One of Paid, Declined, Deleted, Pending, Refunded, Fraud, Other. Can be null. LastChargeStatus string `json:"last_charge_status"` // The creator's notes on the member. Note string `json:"note"` // The amount in cents the user will pay at the next pay cycle. WillPayAmountCents int `json:"will_pay_amount_cents"` }
MemberAttributes represents membership attributes.
type OAuthClient ¶
type OAuthClient struct { *OAuthClientAttributes // The user who created the OAuth Client. User *User // The campaign of the user who created the OAuth Client. Campaign *Campaign // The token of the user who created the client. CreatorToken string }
OAuthClient represents a client created by a developer, used for getting OAuth2 access tokens.
type OAuthClientAttributes ¶
type OAuthClientAttributes struct { // The client's secret. ClientSecret string `json:"client_secret"` // The name provided during client setup. Name string `json:"name"` // The description provided during client setup. Description string `json:"description"` // The author name provided during client setup. Can be null. AuthorName string `json:"author_name"` // The domain provided during client setup. Can be null. Domain string `json:"domain"` // The Patreon API version the client is targeting. Version int `json:"version"` // The URL of the icon used in the OAuth authorization flow. Can be null. IconURL string `json:"icon_url"` // The URL of the privacy policy provided during client setup. Can be null. PrivacyPolicyURL string `json:"privacy_policy_url"` // The URL of the terms of service provided during client setup. Can be null. TOSURL string `json:"tos_url"` // The allowable redirect URIs for the OAuth authorization flow. RedirectURIs string `json:"redirect_uris"` // The client's default OAuth scopes for the authorization flow (Deprecated in APIv2). DefaultScopes string `json:"default_scopes"` }
OAuthClientAttributes represents a client's attributes.
type RequestOpt ¶
type RequestOpt func(*options)
func WithFields ¶
func WithFields(resource string, fields ...string) RequestOpt
WithFields specifies the resource attributes you want to be returned by API.
func WithIncludes ¶
func WithIncludes(include ...string) RequestOpt
WithIncludes specifies the related resources you want to be returned by API.
func WithPageSize ¶
func WithPageSize(size int) RequestOpt
WithPageSize specifies the number of items to return.
type SocialConnection ¶
type SocialConnections ¶
type SocialConnections struct { DeviantArt *SocialConnection `json:"deviantart"` Discord *SocialConnection `json:"discord"` Facebook *SocialConnection `json:"facebook"` Spotify *SocialConnection `json:"spotify"` Twitch *SocialConnection `json:"twitch"` Twitter *SocialConnection `json:"twitter"` Youtube *SocialConnection `json:"youtube"` }
type Tier ¶
type Tier struct { *TierAttributes ID string // The campaign the tier belongs to. Campaign *Campaign // The image file associated with the tier. TierImage *Media // The benefits attached to the tier, which are used for generating deliverables Benefits []*Benefit }
Tier represents a membership level on a campaign, which can have benefits attached to it.
type TierAttributes ¶
type TierAttributes struct { // Monetary amount associated with this tier (in U.S. cents). AmountCents int `json:"amount_cents"` // Maximum number of patrons this tier is limited to, if applicable. Can be null. UserLimit int `json:"user_limit"` // Remaining number of patrons who may subscribe, if there is a user_limit. Can be null. Remaining int `json:"remaining"` // Tier display description. Description string `json:"description"` // true if this tier requires a shipping address from patrons. RequiresShipping bool `json:"requires_shipping"` // Datetime this tier was created. CreatedAt time.Time `json:"created_at"` // Fully qualified URL associated with this tier. URL string `json:"url"` // Number of patrons currently registered for this tier. PatronCount int `json:"patron_count"` // Number of posts published to this tier. Can be null. PostCount int `json:"post_count"` // The discord role IDs granted by this tier. Can be null. DiscordRoleIDs interface{} `json:"discord_role_ids"` // Tier display title. Title string `json:"title"` // Full qualified image URL associated with this tier. Can be null. ImageURL string `json:"image_url"` // Datetime tier was last modified. EditedAt time.Time `json:"edited_at"` // true if the tier is currently published. Published bool `json:"published"` // Datetime this tier was last published. Can be null. PublishedAt time.Time `json:"published_at"` // Datetime tier was unpublished, while applicable. Can be null. UnpublishedAt time.Time `json:"unpublished_at"` }
TierAttributes represents a membership level attributes.
type User ¶
type User struct { *UserAttributes ID string // Usually a zero or one-element array with the user's membership to the token creator's campaign, // if they are a member. With the identity.memberships scope, this returns memberships to ALL campaigns the user is // a member of. Memberships []*Member Campaign *Campaign }
User represents the Patreon user, which can be both patron and creator.
type UserAttributes ¶
type UserAttributes struct { // The user's email address. Requires certain scopes to access. See the scopes section of this documentation. Email string `json:"email"` // First name. Can be null. FirstName string `json:"first_name"` // Last name. Can be null. LastName string `json:"last_name"` // Combined first and last name. FullName string `json:"full_name"` // true if the user has confirmed their email. IsEmailVerified bool `json:"is_email_verified"` // The public "username" of the user. patreon.com/ goes to this user's creator page. // Non-creator users might not have a vanity. Can be null. Vanity string `json:"vanity"` // The user's about text, which appears on their profile. Can be null. About string `json:"about"` // The user's profile picture URL, scaled to width 400px. ImageURL string `json:"image_url"` // The user's profile picture URL, scaled to a square of size 100x100px. ThumbURL string `json:"thumb_url"` // true if this user can view nsfw content. Can be null. CanSeeNSFW bool `json:"can_see_nsfw"` // Datetime of this user's account creation. Created time.Time `json:"created"` // URL of this user's creator or patron profile. URL string `json:"url"` // How many posts this user has liked. LikeCount int `json:"like_count"` // true if the user has chosen to keep private which creators they pledge to. Can be null. HidePledges bool `json:"hide_pledges"` // Mapping from user's connected app names to external user id on the respective app. SocialConnections SocialConnections `json:"social_connections"` }
UserAttributes represent the Patreon user attributes.
type Webhook ¶
type Webhook struct { WebhookAttributes // The client which created the webhook Client *OAuthClient // The campaign whose events trigger the webhook. Campaign *Campaign }
Webhook represents an event happening on a particular campaign.
type WebhookAttributes ¶
type WebhookAttributes struct { // List of events that will trigger this webhook. Triggers []string `json:"triggers"` // Fully qualified uri where webhook will be sent (e.g. https://www.example.com/webhooks/incoming). URI string `json:"uri"` // true if the webhook is paused as a result of repeated failed attempts to post to uri. // Set to false to attempt to re-enable a previously failing webhook. Paused bool `json:"paused"` // Last date that the webhook was attempted or used. LastAttemptedAt time.Time `json:"last_attempted_at"` // Number of times the webhook has failed consecutively, when in an error state. NumConsecutiveTimesFailed int `json:"num_consecutive_times_failed"` // Secret used to sign your webhook message body, so you can validate authenticity upon receipt. Secret string `json:"secret"` }
WebhookAttributes represent webhook attributes.