model

package
v0.0.0-...-c53624e Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        AccountID
	Name      string
	CPF       CPF
	Secret    string
	Balance   Money
	CreatedAt time.Time
}

Account represents a bank account.

func NewAccount

func NewAccount(name string, cpf string, secret string, balance float64) *Account

NewAccount returns a new Account filled with the corresponding arguments with generated values for id and createdAt.

func (*Account) CompareSecrets

func (a *Account) CompareSecrets(secret string) error

CompareSecrets compare account secret and payload.

func (*Account) HashSecret

func (a *Account) HashSecret() error

HashSecret hashes secret with bcrypt.

type AccountID

type AccountID string

AccountID represents an Account ID as uuid.

func NewAccountID

func NewAccountID() AccountID

NewAccountID returns a new AccountID with value generated by uuid.New().

type CPF

type CPF string

CPF represents the Brazilian taxpayer ID, know as CPF.

func NewCPF

func NewCPF(cpf string) CPF

NewCPF instantiates a new CPF. It removes the non-digits from the input, if any

func (*CPF) String

func (c *CPF) String() string

String returns a formatted CPF (000.000.000-00)

type Money

type Money int64

Money represents monetary amount. It is an integer to prevent floating point math problems.

func Float64ToMoney

func Float64ToMoney(f float64) Money

Float64ToMoney converts float64 to Money

func (Money) Float64

func (m Money) Float64() float64

Float64 converts Money to float64

func (Money) Int64

func (m Money) Int64() int64

Int64 converts Money to int64

type Transfer

type Transfer struct {
	ID                   TransferID
	AccountOriginID      AccountID
	AccountDestinationID AccountID
	Amount               Money
	CreatedAt            time.Time
}

Transfer represents a bank transfer between two accounts.

func NewTransfer

func NewTransfer(accountOriginID, accountDestinationID string, amount float64) *Transfer

NewTransfer returns a new Transfer filled with the corresponding arguments with generated values for id and createdAt.

type TransferID

type TransferID string

TransferID represents a Transfer ID as uuid

func NewTransferID

func NewTransferID() TransferID

NewTransferID returns a new TransferID with value generated by uuid.New()

Jump to

Keyboard shortcuts

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