patreonapi

package
v1.20.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2019 License: MIT Imports: 7 Imported by: 0

README

Basic makeshift api implementatino for patreon v2 api, only works for yags needs as i couldn't be arsed to add in all options and such.

Needed because v1 api dosen't suit my needs (cancelling a pledge, wile it was paid that month isnt handled by v1)

Documentation

Index

Constants

View Source
const (
	// AuthorizationURL specifies Patreon's OAuth2 authorization endpoint (see https://tools.ietf.org/html/rfc6749#section-3.1).
	// See Example_refreshToken for examples.
	AuthorizationURL = "https://www.patreon.com/oauth2/authorize"

	// AccessTokenURL specifies Patreon's OAuth2 token endpoint (see https://tools.ietf.org/html/rfc6749#section-3.2).
	// See Example_refreshToken for examples.
	AccessTokenURL = "https://api.patreon.com/oauth2/token"
)
View Source
const (
	ChargeStatusPaid     = "Paid"
	ChargeStatusDeclined = "Declined"
	ChargeStatusDeleted  = "Deleted"
	ChargeStatusPending  = "Pending"
	ChargeStatusRefunded = "Refunded"
	ChargeStatusFraud    = "Fraud"
	ChargeStatusOther    = "Other"
)
View Source
const APIBase = "https://www.patreon.com/api/oauth2/v2"

Variables

View Source
var TypeMap = map[string]interface{}{
	"user": UserAttributes{},
}

Functions

func DecodeInclude

func DecodeInclude(include *Include) (interface{}, error)

func DecodeIncludes

func DecodeIncludes(includes []*Include) error

Types

type CampaignAttributes

type CampaignAttributes struct {
}

type CampaignData

type CampaignData struct {
	ID         string              `json:"id"`
	Type       string              `json:"type"`
	Attributes *CampaignAttributes `json:"attributes"`
}

type CampaignsResponse

type CampaignsResponse struct {
	Data []*CampaignData `json:"data"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(client *http.Client) *Client

func (*Client) FetchCampaigns

func (c *Client) FetchCampaigns() (r *CampaignsResponse, err error)

func (*Client) FetchMembers

func (c *Client) FetchMembers(campaign string, count int, cursor string) (r *MembersResponse, err error)

func (*Client) FetchUser

func (c *Client) FetchUser() (r *UserResponse, err error)

Sample response with email scope for /identity?fields[user]=about,created,email,first_name,full_name,image_url,last_name,social_connections,thumb_url,url,vanity

func (*Client) Get

func (c *Client) Get(path string, dataDst interface{}) error

type Cursors

type Cursors struct {
	Next string `json:"next"`
}

type Include

type Include struct {
	Type string `json:"type"`
	ID   string `json:"id"`

	Attributes json.RawMessage `json:"attributes"`
	Decoded    interface{}     `json:"-"`
}

type MemberAttributes

type MemberAttributes struct {
	FullName                   string `json:"full_name"`
	IsFollower                 bool   `json:"is_follower"`
	LastChargeData             string `json:"last_charge_date"`
	LastChargeStatus           string `json:"last_charge_status"`
	LifetimeSupportCents       int    `json:"lifetime_support_cents"`
	CurrentEntitledAmountCents int    `json:"currently_entitled_amount_cents"`
	PatronStatus               string `json:"patron_status"`
}

type MemberData

type MemberData struct {
	Type          string        `json:"type"`
	ID            string        `json:"id"`
	Relationships Relationships `json:"relationships"`

	Attributes *MemberAttributes `json:attributes"`
}

type MembersResponse

type MembersResponse struct {
	Data     []*MemberData `json:"data"`
	Included []*Include    `json:"included"`
	Meta     Meta          `json:"meta"`
}

type Meta

type Meta struct {
	Pagination *Pagination `json:"pagination"`
}

type Pagination

type Pagination struct {
	Cursors Cursors `json:"cursors"`
	Total   int     `json:"total"`
}

type RelationShip

type RelationShip struct {
	Data *RelationshipData `json"data"`
}

type RelationshipData

type RelationshipData struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

type Relationships

type Relationships struct {
	User RelationShip `json:"user"`
}

type SocialConnection

type SocialConnection struct {
	UserID string `json:"user_id"`
}

type SocialConnections

type SocialConnections struct {
	Discord *SocialConnection `json:"discord"`
}

type UserAttributes

type UserAttributes struct {
	About   string `json:"about"`
	Created string `json:"created"`
	Email   string `json:"email"`

	Vanity    string `json:"vanity"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	FullName  string `json:"full_name"`

	ImageURL string `json:"image_url"`
	ThumbURL string `json:"thumb_url"`

	SocialConnections *SocialConnections `json:"social_connections"`
}

type UserResponse

type UserResponse struct {
	Data UserResponseData `json:"data"`
}

type UserResponseData

type UserResponseData struct {
	ID         string          `json:"id"`
	Type       string          `json:"type"`
	Attributes *UserAttributes `json:"attributes"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL