package service

import (
	"context"

	"git.gocasts.ir/ebhomengo/niki/domain/wallet/param"
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)

func (s Service) GetUserWallet(ctx context.Context, request param.WalletRequest) (param.WalletResponse, error) {
	const op = richerror.Op("wallet.service.GetUserWallet")

	wallet, err := s.repo.GetWalletByUserID(ctx, request.UserID)

	if err != nil {
		return param.WalletResponse{}, err
	}

	return param.WalletResponse{
		Wallet: param.WalletInfo{
			Balance:   wallet.Balance,
			UpdatedAt: wallet.UpdatedAt,
			Status:    wallet.Status,
		},
	}, nil

}
