feat: update constants and validation for stars and payment methods; refactor enums for clarity

This commit is contained in:
bohd4nx
2026-05-29 22:11:03 +03:00
parent 5c472b68a2
commit 66bcd22198
7 changed files with 62 additions and 45 deletions
+5 -4
View File
@@ -1,7 +1,7 @@
from __future__ import annotations
import json
from typing import Any, cast, get_args
from typing import Any, cast
from pyfragment.core.constants import DEFAULT_TIMEOUT, FRAGMENT_BASE_URL, REQUIRED_COOKIE_KEYS
from pyfragment.domains.ads.service import AdsService
@@ -82,13 +82,14 @@ class FragmentClient:
@staticmethod
def _normalize_wallet_version(wallet_version: str) -> WalletVersion:
version = wallet_version.strip().upper()
if version not in get_args(WalletVersion):
try:
return WalletVersion(version)
except ValueError:
raise ConfigurationError(
ConfigurationError.UNSUPPORTED_VERSION.format(
version=version, supported=", ".join(sorted(get_args(WalletVersion)))
version=version, supported=", ".join(sorted(m.value for m in WalletVersion))
)
)
return cast(WalletVersion, version)
def __init__(
self,