transactions

package
v0.0.0-...-c74069a Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Service Service
}

func NewHandler

func NewHandler(service Service) Handler

func (*Handler) CreateTransactionHandler

func (h *Handler) CreateTransactionHandler(c *fiber.Ctx) error

func (*Handler) GetTransactionHistoryHandler

func (h *Handler) GetTransactionHistoryHandler(c *fiber.Ctx) error

func (*Handler) SetupApp

func (h *Handler) SetupApp(app *fiber.App)

type Repository

type Repository struct {
	MongoClient *mongo.Client
}

func NewRepository

func NewRepository(uri string) Repository

func (*Repository) CreateTransaction

func (r *Repository) CreateTransaction(transaction Transaction) (*Transaction, error)

func (*Repository) GetTransaction

func (r *Repository) GetTransaction(ID string) (*Transaction, error)

func (*Repository) GetTransactionHistory

func (r *Repository) GetTransactionHistory(UserID string) ([]Transaction, error)

type Service

type Service struct {
	Repository Repository
}

func NewService

func NewService(repository Repository) Service

func (*Service) CreateTransaction

func (s *Service) CreateTransaction(transactionDTO TransactionDTO) (*Transaction, error)

func (*Service) GetTransactionHistory

func (s *Service) GetTransactionHistory(userId string) ([]Transaction, error)

type Transaction

type Transaction struct {
	ID              string    `json:"id"`
	UserID          string    `json:"user_id"`
	Symbol          string    `json:"symbol"`
	Amount          float64   `json:"amount"`
	BuyingPrice     float64   `json:"buying_price"`
	CreatedAt       time.Time `json:"createdAt"`
	TransactionType string    `json:"transaction_type"`
}

type TransactionDTO

type TransactionDTO struct {
	UserID          string  `json:"user_id"`
	Symbol          string  `json:"symbol"`
	Amount          float64 `json:"amount"`
	BuyingPrice     float64 `json:"buying_price"`
	TransactionType string  `json:"transaction_type"`
}

type TransactionEntity

type TransactionEntity struct {
	ID              string    `bson:"id"`
	UserID          string    `bson:"user_id"`
	Symbol          string    `bson:"symbol"`
	Amount          float64   `bson:"amount"`
	BuyingPrice     float64   `bson:"buying_price"`
	CreatedAt       time.Time `bson:"createdAt"`
	TransactionType string    `bson:"transaction_type"`
}

Jump to

Keyboard shortcuts

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