entity

package
v0.0.0-...-767f277 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternalServerError will throw if any the Internal Server Error happen
	ErrInternalServerError = errors.New("internal Server Error")
	// ErrNotFound will throw if the requested item is not exists
	ErrNotFound = errors.New("your requested Item is not found")
	// ErrConflict will throw if the current action already exists
	ErrConflict = errors.New("your Item already exist")
	// ErrBadParamInput will throw if the given request-body or params is not valid
	ErrBadParamInput = errors.New("given Param is not valid")
)

Functions

This section is empty.

Types

type Exchange

type Exchange struct {
	Currency string  `json:"currency"`
	Rate     float64 `json:"rate"`
}

func NewExchange

func NewExchange(currency string, rate float64) Exchange

type ExchangeRepository

type ExchangeRepository interface {
	GetByCurrency(ctx context.Context, currency string) (Exchange, error)
}

Exchange repository

type Transaction

type Transaction struct {
	//TODO ID
	ID              int64           `json:"id"`
	WalletId        int64           `json:"wallet_id" binding:"required"`
	TransactionType TransactionType `json:"transactionType" binding:"required,oneof=deposit withdraw"`
	Amount          float64         `json:"amount" binding:"required"`
	Currency        string          `json:"currency" binding:"required,iso4217"`
	CreatedAt       time.Time       `json:"created_at"`
}

func NewTransaction

func NewTransaction(walletId int64, transactionType TransactionType, currency string, amount float64) Transaction

type TransactionRepository

type TransactionRepository interface {
	Store(ctx context.Context, t Transaction) error
	GetHistory(ctx context.Context) ([]Transaction, error)
}

Transaction Repository

type TransactionType

type TransactionType string
const (
	Deposit    TransactionType = "deposit"
	Withdrawal TransactionType = "withdrawal"
)

type TransactionUseCase

type TransactionUseCase interface {
	History(ctx context.Context) ([]Transaction, error)
	Post(ctx context.Context, t Transaction) error
}

type User

type User struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email" binding:"required,email"`
}

func NewUser

func NewUser(name, email string) User

type UserRepository

type UserRepository interface {
	Store(ctx context.Context, u User) error
	Update(ctx context.Context, u User) error
}

User Repository

type UserUseCase

type UserUseCase interface {
	Store(ctx context.Context, u User) error
}

User Usecase

type Wallet

type Wallet struct {
	ID       int64   `json:"id"`
	UserId   int64   `json:"user_id"`
	Balance  float64 `json:"balance"`
	Currency string  `json:"currency"`
}

func NewWallet

func NewWallet(userId int64, currency string, balance float64) Wallet

type WalletRepository

type WalletRepository interface {
	Get(ctx context.Context, id int64) (Wallet, error)
	Store(ctx context.Context, w Wallet) error
	Update(ctx context.Context, w Wallet) error
	GetWalletsByUser(ctx context.Context, id int64) ([]Wallet, error)
}

Wallet Repository

type WalletUseCase

type WalletUseCase interface {
	Store(ctx context.Context, w Wallet) error
	GetWalletsByUser(ctx context.Context, id int64) ([]Wallet, error)
}

Wallet Usecase

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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