services

package
v0.0.0-...-7b078d6 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized = errors.New("Unauthorized")
	ErrUserNotFound = errors.New("user not found")
)
View Source
var (
	ErrInvalidAmount       = errors.New("invalid amount")
	ErrInsufficientBalance = errors.New("insufficient balance")
)

Functions

This section is empty.

Types

type IUserService

type IUserService interface {
	GetUserByName(name string) (*models.User, bool, error)
}

type IWalletService

type IWalletService interface {
	Deposit(userID uint, currency string, amount decimal.Decimal) error
	Withdraw(userID uint, currency string, amount decimal.Decimal) error
	Transfer(senderID, recipientID uint, currency string, amount decimal.Decimal, memo string) error
	GetBalances(userID uint, currencies []string) ([]models.Vault, error)
	GetTransactionHistory(userID uint, txnType models.TransactionType, cursor string, order SortOrder, limit int) ([]models.Transaction, string, error)
}

type SortOrder

type SortOrder int
const (
	SortOrderAsc SortOrder = iota
	SortOrderDesc
)

type UserService

type UserService struct {
	DB *gorm.DB
}

UserService represents the service for user-related operations

func NewUserService

func NewUserService(db *gorm.DB) *UserService

func (*UserService) GetUserByName

func (svc *UserService) GetUserByName(name string) (*models.User, bool, error)

type WalletService

type WalletService struct {
	DB *gorm.DB
}

WalletService represents the service for wallet-related operations

func NewWalletService

func NewWalletService(db *gorm.DB) *WalletService

func (*WalletService) Deposit

func (s *WalletService) Deposit(userID uint, currency string, amount decimal.Decimal) error

func (*WalletService) GetBalances

func (s *WalletService) GetBalances(userID uint, currencies []string) ([]models.Vault, error)

func (*WalletService) GetTransactionHistory

func (s *WalletService) GetTransactionHistory(
	userID uint, txnType models.TransactionType, cursor string, order SortOrder, limit int) ([]models.Transaction, string, error)

GetTransactionHistory retrieves paginated transaction history using a unique cursor with filters

func (*WalletService) Transfer

func (s *WalletService) Transfer(senderID, recipientID uint, currency string, amount decimal.Decimal, memo string) error

func (*WalletService) Withdraw

func (s *WalletService) Withdraw(userID uint, currency string, amount decimal.Decimal) error

Jump to

Keyboard shortcuts

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