ContributionResult

What the current user has contributed to the configured targets.

On this page

Class in sponsorkit.models.

from sponsorkit import ContributionResult

Also importable from sponsorkit.models.

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

What the current user has contributed to the configured targets.

The helper methods filter contributions; they never sum across providers or currencies.

Constructor#

ContributionResult(
    signed_in: bool,
    disabled: bool,
    mock: bool,
    targets: tuple[str, ...],
    supporter: Supporter | None,
    contributions: tuple[Contribution, ...],
    fetched_at: str | None,
    stale: bool,
    from_cache: bool,
    unavailable: tuple[Provider, ...] | None = None,
) -> None

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

Fields#

signed_in#

signed_in: bool

Whether a session is stored for this target set.

disabled#

disabled: bool

True when SPONSORKIT_DISABLE is set; the result is then signed out and empty.

mock#

mock: bool

True when the result comes from mock mode.

targets#

targets: tuple[str, ...]

The canonical target strings, e.g. ("github:octocat",).

supporter#

supporter: Supporter | None

The signed-in supporter, or None when signed out.

contributions#

contributions: tuple[Contribution, ...]

Every contribution the supporter (or an organization they belong to) made to the targets.

fetched_at#

fetched_at: str | None

ISO-8601 time the API produced the result; None for signed-out, disabled and mock results.

stale#

stale: bool

Some provider could not be reached; its data (if any) comes from the local cache.

from_cache#

from_cache: bool

The whole result was served from the local cache.

unavailable#

unavailable: tuple[Provider, ...] | None = None

Providers the API could not query (API results only).

Methods#

active()#

def active(self) -> list[Contribution]

Contributions whose status is active.

recurring()#

def recurring(self) -> list[Contribution]

Recurring contributions (any status).

one_time()#

def one_time(self) -> list[Contribution]

One-time contributions (any status).

by_provider()#

def by_provider(self, provider: Provider) -> list[Contribution]

Contributions made through provider.

direct()#

def direct(self) -> list[Contribution]

Contributions the user made directly (excludes organization sponsorships).

from_dict()#

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

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

to_dict()#

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

The camelCase JSON form (unavailable is omitted when None).