Contribution
A sponsorship (GitHub) or order (Open Collective) to one of the targets.
On this page
Class in sponsorkit.models.
from sponsorkit import ContributionAlso 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,
) -> NoneInstances are immutable; every field below is a constructor parameter.
Fields#
id#
id: strStable id, con_<provider>_....
provider#
provider: Providergithub or open-collective.
target#
target: strTarget string, e.g. github:octocat.
sponsor#
sponsor: SponsorEntityWho 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: Kindrecurring or one_time.
frequency#
frequency: Frequencyone_time, monthly or yearly.
status#
status: StatusNormalized status. Unknown provider statuses map to pending.
amount#
amount: MoneyMinor units. Never converted or summed across currencies.
tier#
tier: Tier | NoneThe provider tier, when there is one.
flags#
flags: tuple[str, ...]Provider-specific markers.
private#
private: boolWhether the supporter made the contribution private on the provider.
started_at#
started_at: str | NoneISO-8601 start time, when known.
ended_at#
ended_at: str | NoneISO-8601 end time, when the contribution ended.
last_charged_at#
last_charged_at: str | NoneISO-8601 time of the last charge, when known.
next_charge_at#
next_charge_at: str | NoneISO-8601 time of the next charge (recurring contributions), when known.
total_contributed#
total_contributed: Money | NoneLifetime total, when the provider reports one.
Methods#
from_dict()#
@classmethod
def from_dict(cls, d: Mapping[str, Any]) -> ContributionParse the camelCase JSON form. Raises TypeError/ValueError/KeyError when malformed.
to_dict()#
def to_dict(self) -> dict[str, Any]The camelCase JSON form.