Contribution

A sponsorship (GitHub) or order (Open Collective) to one of the targets.

On this page

Class in sponsorkit.models.

from sponsorkit import Contribution

Also importable from sponsorkit.models.

@dataclass(frozen=True)
class Contribution:
    ...

A sponsorship (GitHub) or order (Open Collective) to one of the targets.

Constructor#

Contribution(
    id: str,
    provider: Provider,
    target: str,
    sponsor: SponsorEntity,
    via: Literal['direct', 'organization'],
    kind: Kind,
    frequency: Frequency,
    status: Status,
    amount: Money,
    tier: Tier | None,
    flags: tuple[str, ...],
    private: bool,
    started_at: str | None,
    ended_at: str | None,
    last_charged_at: str | None,
    next_charge_at: str | None,
    total_contributed: Money | None,
) -> None

Instances are immutable; every field below is a constructor parameter.

Fields#

id#

id: str

Stable id, con_<provider>_....

provider#

provider: Provider

github or open-collective.

target#

target: str

Target string, e.g. github:octocat.

sponsor: SponsorEntity

Who pays: the supporter or one of their organizations.

via#

via: Literal['direct', 'organization']

direct for the supporter's own contribution, organization for one made by an organization they belong to.

kind#

kind: Kind

recurring or one_time.

frequency#

frequency: Frequency

one_time, monthly or yearly.

status#

status: Status

Normalized status. Unknown provider statuses map to pending.

amount#

amount: Money

Minor units. Never converted or summed across currencies.

tier#

tier: Tier | None

The provider tier, when there is one.

flags#

flags: tuple[str, ...]

Provider-specific markers.

private#

private: bool

Whether the supporter made the contribution private on the provider.

started_at#

started_at: str | None

ISO-8601 start time, when known.

ended_at#

ended_at: str | None

ISO-8601 end time, when the contribution ended.

last_charged_at#

last_charged_at: str | None

ISO-8601 time of the last charge, when known.

next_charge_at#

next_charge_at: str | None

ISO-8601 time of the next charge (recurring contributions), when known.

total_contributed#

total_contributed: Money | None

Lifetime total, when the provider reports one.

Methods#

from_dict()#

@classmethod
def from_dict(cls, d: Mapping[str, Any]) -> Contribution

Parse the camelCase JSON form. Raises TypeError/ValueError/KeyError when malformed.

to_dict()#

def to_dict(self) -> dict[str, Any]

The camelCase JSON form.