pointsmanager

package
v0.0.0-...-732ec5d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BananoCostPerPoint *big.Int = new(big.Int).Div(bananoUnit, big.NewInt(100))

BananoCostPerPoint is the cost of each point in Banano

Functions

This section is empty.

Types

type BananoConversionFlow

type BananoConversionFlow struct {
	// contains filtered or unexported fields
}

BananoConversionFlow represents a Banano to points conversion flow for one user

func (*BananoConversionFlow) Converted

func (*BananoConversionFlow) Destroyed

func (f *BananoConversionFlow) Destroyed() event.NoArgEvent

func (*BananoConversionFlow) Expiration

func (f *BananoConversionFlow) Expiration() time.Time

func (*BananoConversionFlow) Expired

func (f *BananoConversionFlow) Expired() event.NoArgEvent

func (*BananoConversionFlow) PaymentAddress

func (f *BananoConversionFlow) PaymentAddress() string

func (*BananoConversionFlow) SessionBananoTotal

func (f *BananoConversionFlow) SessionBananoTotal() payment.Amount

func (*BananoConversionFlow) SessionPointsTotal

func (f *BananoConversionFlow) SessionPointsTotal() int

type BananoConvertedEventArgs

type BananoConvertedEventArgs struct {
	BananoAmount       payment.Amount
	SessionBananoTotal payment.Amount
	PointsAmount       int
	SessionPointsTotal int
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages user points

func New

func New(workerContext context.Context, log *log.Logger, snowflakeNode *snowflake.Node, paymentAccountPool *payment.PaymentAccountPool) (*Manager, error)

New returns a new initialized Manager

func (*Manager) CreateOrRecoverBananoConversionFlow

func (m *Manager) CreateOrRecoverBananoConversionFlow(user auth.User) (*BananoConversionFlow, error)

func (*Manager) CreateTransaction

func (m *Manager) CreateTransaction(ctxCtx context.Context, forUser auth.User, txType types.PointsTxType, value int, extraFields ...TxExtraField) (*types.PointsTx, error)

CreateTransaction creates a points transaction

func (*Manager) GetCurrentUserSubscription

func (m *Manager) GetCurrentUserSubscription(ctxCtx context.Context, user auth.User) (*types.Subscription, error)

func (*Manager) IsUserCurrentlySubscribed

func (m *Manager) IsUserCurrentlySubscribed(ctxCtx context.Context, user auth.User) (bool, error)

func (*Manager) OnTransactionCreated

func (m *Manager) OnTransactionCreated() event.Event[*types.PointsTx]

OnTransactionCreated returns the event that is fired when a points transaction is committed

func (*Manager) OnTransactionUpdated

func (m *Manager) OnTransactionUpdated() event.Event[TransactionUpdatedEventArgs]

OnTransactionUpdated returns the event that is fired when a points transaction is updated (due to transaction collapsing)

func (*Manager) SubscribeOrExtendSubscription

func (m *Manager) SubscribeOrExtendSubscription(ctxCtx context.Context, user auth.User) (*types.Subscription, error)

type TransactionUpdatedEventArgs

type TransactionUpdatedEventArgs struct {
	Transaction     *types.PointsTx
	AdjustmentValue int
}

TransactionUpdatedEventArgs are the arguments to the OnTransactionUpdated event

type TxExtraField

type TxExtraField struct {
	Key   string
	Value any
}

TxExtraField represents an extra field for a transaction

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL