app.services.wallet_service module¶
- class app.services.wallet_service.WalletService(wallet_repository, user_repository)[source]¶
Bases:
BaseServiceService class for managing wallets.
- Parameters:
wallet_repository (WalletRepository)
user_repository (UserRepository)
- async get_wallet_by_user_id(externalUserId)[source]¶
Return the wallet belonging to an external user.
- Parameters:
externalUserId – External identifier of the user.
- Returns:
BaseWallet – The user’s wallet with coin/point balances and rate.
- Raises:
NotFoundError – If the user or their wallet does not exist.
- Return type:
BaseWallet
- async preview_convert(schema)[source]¶
Preview converting points to coins without persisting anything.
Computes the coins a points amount would yield at the wallet’s current conversion rate and the resulting balances, for display before the user confirms.
- Parameters:
schema – Payload with
externalUserIdandpointsto convert.- Returns:
ResponsePreviewConvertPoints – The projected conversion result and post-conversion balances.
- Raises:
NotFoundError – If the user or their wallet does not exist.
- Return type:
ResponsePreviewConvertPoints