Contribution

Contribution is one sponsorship (GitHub) or order (Open Collective), normalized to one shape across providers.

On this page

Contribution is one sponsorship (GitHub) or order (Open Collective), normalized to one shape across providers. Timestamps are ISO-8601 strings exactly as sent by the API.

type Contribution struct {
	ID               string        `json:"id"`
	Provider         Provider      `json:"provider"`
	Target           string        `json:"target"`
	Sponsor          SponsorEntity `json:"sponsor"`
	Via              Via           `json:"via"`
	Kind             Kind          `json:"kind"`
	Frequency        Frequency     `json:"frequency"`
	Status           Status        `json:"status"`
	Amount           Money         `json:"amount"`
	Tier             *Tier         `json:"tier"`
	Flags            []string      `json:"flags"`
	Private          bool          `json:"private"`
	StartedAt        *string       `json:"startedAt"`
	EndedAt          *string       `json:"endedAt"`
	LastChargedAt    *string       `json:"lastChargedAt"`
	NextChargeAt     *string       `json:"nextChargeAt"`
	TotalContributed *Money        `json:"totalContributed"`
}

Fields#

ID#

ID string `json:"id"`

ID is stable, derived from the provider and its external id.

Provider#

Provider Provider `json:"provider"`

Provider is where the contribution was made.

Target#

Target string `json:"target"`

Target is the target string, e.g. "github:octocat".

Sponsor SponsorEntity `json:"sponsor"`

Sponsor is who pays: the supporter, or an organization they belong to.

Via#

Via Via `json:"via"`

Via is ViaDirect when the supporter pays personally and ViaOrganization when an organization pays.

Kind#

Kind Kind `json:"kind"`

Kind is KindRecurring or KindOneTime.

Frequency#

Frequency Frequency `json:"frequency"`

Frequency is Monthly, Yearly (Open Collective only) or OneTime.

Status#

Status Status `json:"status"`

Status is one of the Status constants. One-time contributions are never StatusActive; a completed one is StatusPaid.

Amount#

Amount Money `json:"amount"`

Amount is the amount per charge, in minor units.

Tier#

Tier *Tier `json:"tier"`

Tier is the provider tier, or nil when there is none.

Flags#

Flags []string `json:"flags"`

Flags may contain "via_patreon" (a GitHub sponsorship paid through Patreon).

Private#

Private bool `json:"private"`

Private is true when the supporter made the contribution private (GitHub) or incognito (Open Collective). Don't display it publicly.

StartedAt#

StartedAt *string `json:"startedAt"`

StartedAt is when the contribution started, or nil.

EndedAt#

EndedAt *string `json:"endedAt"`

EndedAt is when the contribution ended, or nil.

LastChargedAt#

LastChargedAt *string `json:"lastChargedAt"`

LastChargedAt is the last charge (Open Collective only), or nil.

NextChargeAt#

NextChargeAt *string `json:"nextChargeAt"`

NextChargeAt is the next charge (Open Collective only), or nil.

TotalContributed#

TotalContributed *Money `json:"totalContributed"`

TotalContributed is everything paid so far (Open Collective only), or nil.

Methods#

MarshalJSON#

func (c Contribution) MarshalJSON() ([]byte, error)

MarshalJSON encodes a nil Flags slice as [].

View source