package wallet

import "errors"

var (
	ErrDependencyUnavailable = errors.New("dependency unavailable")
	ErrInvalidAmount         = errors.New("invalid amount")
	ErrInsufficientBalance   = errors.New("insufficient balance")
	ErrFeaturePending        = errors.New("feature pending")
	ErrRechargeDisabled      = errors.New("wallet recharge disabled")
)

const MinRechargeAmount = 0.01

type Service struct {
	repo *Repository
}

func NewService(repo *Repository) *Service {
	return &Service{repo: repo}
}

func (s *Service) Account(userID uint64) (*AccountDTO, error) {
	if s.repo == nil {
		return nil, ErrDependencyUnavailable
	}
	return s.repo.Account(userID)
}

func (s *Service) Ledger(userID uint64, page, pageSize int) (*PaginatedResult, error) {
	if s.repo == nil {
		return nil, ErrDependencyUnavailable
	}
	return s.repo.Ledger(userID, page, pageSize)
}

func (s *Service) Recharge(userID uint64, req RechargeRequest) (*AccountDTO, error) {
	if s.repo == nil {
		return nil, ErrDependencyUnavailable
	}
	return nil, ErrRechargeDisabled
}

func (s *Service) Withdraw(userID uint64, req WithdrawRequest) (*AccountDTO, error) {
	if s.repo == nil {
		return nil, ErrDependencyUnavailable
	}
	return nil, ErrFeaturePending
}

func (s *Service) AdminLedger(query AdminLedgerQuery) (*PaginatedResult, error) {
	if s.repo == nil {
		return nil, ErrDependencyUnavailable
	}
	return s.repo.AdminLedger(query)
}
