patreon

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	Email                   string    `json:"email"`
	LastChargeDate          time.Time `json:"last_charge_date"`
	LastChargeStatus        string    `json:"last_charge_status"`
	PatronStatus            string    `json:"patron_status"`
	PledgeRelationshipStart time.Time `json:"pledge_relationship_start"`
}

type Client

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

func NewClient

func NewClient(config config.Config, logger *zap.Logger, tokens Tokens) *Client

func (*Client) DoRefresh

func (c *Client) DoRefresh(ctx context.Context) (Tokens, error)

func (*Client) FetchPage

func (c *Client) FetchPage(ctx context.Context, url string) (PledgeResponse, error)

func (*Client) FetchPageWithTimeout

func (c *Client) FetchPageWithTimeout(ctx context.Context, timeout time.Duration, url string) (PledgeResponse, error)

func (*Client) FetchPledges

func (c *Client) FetchPledges(ctx context.Context) (map[string]Patron, error)

type Member

type Member struct {
	Attributes    Attributes `json:"attributes"`
	Relationships struct {
		User struct {
			Data struct {
				Id uint64 `json:"id,string"`
			} `json:"data"`
		} `json:"user"`
		CurrentlyEntitledTiers struct {
			Data []struct {
				TierId uint64 `json:"id,string"`
			} `json:"data"`
		} `json:"currently_entitled_tiers"`
	} `json:"relationships"`
}

type Patron

type Patron struct {
	Attributes
	Id        uint64
	Tiers     []Tier
	DiscordId *uint64
}

type PatronMetadata

type PatronMetadata struct {
	Id         uint64 `json:"id,string"`
	Attributes struct {
		SocialConnections struct {
			Discord struct {
				Id *uint64 `json:"user_id,string"`
			} `json:"discord"`
		} `json:"social_connections"`
	} `json:"attributes"`
}

type PledgeResponse

type PledgeResponse struct {
	Data     []Member         `json:"data"`
	Included []PatronMetadata `json:"included"`
	Links    *struct {
		First string  `json:"first"`
		Next  *string `json:"next"`
	} `json:"links"`
}

type RefreshResponse

type RefreshResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int64  `json:"expires_in"` // Seconds
	Scope        string `json:"scope"`
	TokenType    string `json:"token_type"`
}

type Tier

type Tier int
const (
	Premium Tier = iota
	Whitelabel
)

func GetTierFromId

func GetTierFromId(id uint64) (Tier, bool)

func (Tier) String

func (i Tier) String() string

type Tokens

type Tokens struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresAt    time.Time `json:"expires_at"`
}

Jump to

Keyboard shortcuts

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