diff options
| author | stuppie | 2026-09-28 15:15:28 -0600 |
|---|---|---|
| committer | stuppie | 2026-09-28 15:15:28 -0600 |
| commit | 6b1424f8c87f644f50fb754cbcf6a616030fb7a3 (patch) | |
| tree | d37ff9a0f80d686ab6e96addd89dcdf10be7942b | |
| parent | 358343bb3ba4908487b275c97a08bfe514ea1a9c (diff) | |
| download | generalresearch-6b1424f8c87f644f50fb754cbcf6a616030fb7a3.tar.gz generalresearch-6b1424f8c87f644f50fb754cbcf6a616030fb7a3.zip | |
add a payout method categoryv3.6.2
| -rw-r--r-- | generalresearch/models/thl/wallet/cashout_method.py | 25 | ||||
| -rw-r--r-- | generalresearch/models/thl/wallet/definitions.py | 31 | ||||
| -rw-r--r-- | pyproject.toml | 2 |
3 files changed, 47 insertions, 11 deletions
diff --git a/generalresearch/models/thl/wallet/cashout_method.py b/generalresearch/models/thl/wallet/cashout_method.py index af3dcda..c0a43c9 100644 --- a/generalresearch/models/thl/wallet/cashout_method.py +++ b/generalresearch/models/thl/wallet/cashout_method.py @@ -14,6 +14,7 @@ from pydantic import ( Field, NonNegativeInt, PositiveInt, + computed_field, field_validator, model_validator, ) @@ -29,7 +30,12 @@ from generalresearch.models.thl.definitions import PayoutStatus from generalresearch.models.thl.locales import CountryISO from generalresearch.models.thl.user_identifiers import BPUIDStr from generalresearch.models.thl.user_ref import UserRef -from generalresearch.models.thl.wallet.definitions import Currency, PayoutType +from generalresearch.models.thl.wallet.definitions import ( + PAYOUT_TYPE_TO_CATEGORY, + Currency, + PayoutCategory, + PayoutType, +) if TYPE_CHECKING: from generalresearch.models.thl.payout import UserPayoutEvent @@ -113,15 +119,6 @@ class CashoutMethodBase(BaseModel): "The minimum amount that can be cashed out in one transaction.", ) - # - # @property - # def min_value_usd(self): - # if self.original_currency == Currency.USD: - # return self.min_value - # if self.usd_exchange_rate is None: - # return None - # return self.min_value * self.usd_exchange_rate - @model_validator(mode="after") def validate_value_ranges(self) -> Self: if self.min_value > self.max_value: @@ -205,6 +202,10 @@ class CashoutMethodOut(CashoutMethodBase): d["product_user_id"] = cm.user.product_user_id return cls.model_validate(d) + @computed_field + def category(self) -> PayoutCategory: + return PAYOUT_TYPE_TO_CATEGORY[self.type] + class USDeliveryAddress(BaseModel): name_or_attn: str = Field(min_length=1, max_length=50) @@ -432,6 +433,10 @@ class CashoutRequestSummary(BaseModel): ) created: AwareDatetimeISO = Field() + @computed_field + def category(self) -> PayoutCategory: + return PAYOUT_TYPE_TO_CATEGORY[self.payout_type] + @classmethod def from_payout_event(cls, pe: UserPayoutEvent) -> Self: return cls( diff --git a/generalresearch/models/thl/wallet/definitions.py b/generalresearch/models/thl/wallet/definitions.py index 5f18e38..96b639c 100644 --- a/generalresearch/models/thl/wallet/definitions.py +++ b/generalresearch/models/thl/wallet/definitions.py @@ -3,6 +3,21 @@ from enum import StrEnum from generalresearch.utils.enum import ReprEnumMeta +class PayoutCategory(StrEnum, metaclass=ReprEnumMeta): + # PayPal, Zelle, ACH, wire, Dwolla, Venmo, cash-in-mail + CASH = "CASH" + # Tango, Tremendous + GIFT_CARD = "GIFT_CARD" + # Physical or non-cash prizes + PRIZE = "PRIZE" + # Blockchain-based transferable assets + CRYPTO = "CRYPTO" + # Value credited directly to a closed platform ecosystem. + # e.g., in-game currency, steam points, airline miles + # Could also be called "Virtual Currency" + PLATFORM_CREDIT = "PLATFORM_CREDIT" + + class PayoutType(StrEnum, metaclass=ReprEnumMeta): """ The method in which the requested payout is delivered. @@ -37,6 +52,21 @@ class PayoutType(StrEnum, metaclass=ReprEnumMeta): AMT_ASSIGNMENT = "AMT_ASSIGNMENT" +PAYOUT_TYPE_TO_CATEGORY = { + PayoutType.PAYPAL: PayoutCategory.CASH, + PayoutType.TANGO: PayoutCategory.GIFT_CARD, + PayoutType.TREMENDOUS: PayoutCategory.GIFT_CARD, + PayoutType.DWOLLA: PayoutCategory.CASH, + PayoutType.ACH: PayoutCategory.CASH, + PayoutType.WIRE: PayoutCategory.CASH, + PayoutType.CASH_IN_MAIL: PayoutCategory.CASH, + PayoutType.PRIZE: PayoutCategory.PRIZE, + PayoutType.AMT: PayoutCategory.PLATFORM_CREDIT, + PayoutType.AMT_BONUS: PayoutCategory.PLATFORM_CREDIT, + PayoutType.AMT_HIT: PayoutCategory.PLATFORM_CREDIT, + PayoutType.AMT_ASSIGNMENT: PayoutCategory.PLATFORM_CREDIT, +} + class Currency(StrEnum, metaclass=ReprEnumMeta): # United States Dollar. Smallest Unit: Cents. USD = "USD" @@ -59,6 +89,7 @@ class Currency(StrEnum, metaclass=ReprEnumMeta): # Mexican Peso. Smallest Unit: Centavos. MXN = "MXN" + SUPPORTED_CURRENCIES = {currency.value for currency in Currency} diff --git a/pyproject.toml b/pyproject.toml index 47c5c14..56a29af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "generalresearch" -version = "3.6.1" +version = "3.6.2" description = "Python Utilities for General Research" readme = "README.md" requires-python = ">=3.14" |
