app.services.wallet_service module

class app.services.wallet_service.WalletService(wallet_repository, user_repository)[source]

Bases: BaseService

Service class for managing wallets.

Parameters:
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 externalUserId and points to 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