domain

package
v0.0.0-...-a64fb18 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// OperationCompraAVista representa uma operação de compra a vista
	OperationCompraAVista = newOperation(uint64(1), "compra a vista")

	// OperationCompraParcelada representa uma operação de compra parcelada
	OperationCompraParcelada = newOperation(uint64(2), "compra parcelada")

	// OperationSaque representa uma operação de saque
	OperationSaque = newOperation(uint64(3), "saque")

	// OperationPagamento representa uma operação de pagamento
	OperationPagamento = newOperation(uint64(4), "Pagamento")
)

Functions

This section is empty.

Types

type Account

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

Account contains all account's data

func NewAccount

func NewAccount(documentNumber DocumentNumber) (*Account, error)

NewAccount creates a new Account struct

func (*Account) CreatedAt

func (a *Account) CreatedAt() time.Time

CreatedAt returns the createdAt value

func (*Account) Document

func (a *Account) Document() *Document

Document returns the document value

func (*Account) ID

func (a *Account) ID() *ID

ID returns the id value

func (*Account) Store

func (a *Account) Store(repo AccountRepositoryWriter) (*Account, error)

Store stores an account given a Repository

func (*Account) WithCreateAt

func (a *Account) WithCreateAt(t time.Time) *Account

WithCreateAt returns a new Account struct with the informed createAt value

func (*Account) WithID

func (a *Account) WithID(id *ID) *Account

WithID returns a new Account struct with the informed ID value

type AccountRepositoryMock

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

AccountRepositoryMock is a fake representation of an AccountRepositoryWriter, useful to create unit tests

func NewAccountRepositoryMock

func NewAccountRepositoryMock(id *ID, acc *Account, err error) *AccountRepositoryMock

NewAccountRepositoryMock builds a new AccountRepositoryMock struct with its mock results

func (AccountRepositoryMock) FindOneByID

func (a AccountRepositoryMock) FindOneByID(_ *ID) (*Account, error)

FindOneByID finds an account by its id

func (AccountRepositoryMock) Store

func (a AccountRepositoryMock) Store(_ *Account) (*ID, error)

Store stores an account

type AccountRepositoryReader

type AccountRepositoryReader interface {
	FindOneByID(*ID) (*Account, error)
}

AccountRepositoryReader represents the behaviour of the Account Repository to read operation

type AccountRepositoryWriter

type AccountRepositoryWriter interface {
	Store(*Account) (*ID, error)
}

AccountRepositoryWriter represents the behaviour of the Account Repository to write operation

type Document

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

Document represents a customer's document

func NewDocument

func NewDocument(number DocumentNumber) (*Document, error)

NewDocument build a new Documents with its dependencies

func (Document) Number

func (d Document) Number() DocumentNumber

Number returns the value of document number

type DocumentNumber

type DocumentNumber string

DocumentNumber represents the document's number

func (DocumentNumber) String

func (d DocumentNumber) String() string

String cast the document number value to string

type ErrDomain

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

ErrDomain represents an well known domain error

func NewErrDomain

func NewErrDomain(field string, description string) *ErrDomain

NewErrDomain build a new ErrDomain struct

func (ErrDomain) Description

func (e ErrDomain) Description() string

Description returns the description of the error

func (ErrDomain) Error

func (e ErrDomain) Error() string

Error returns a formatted error message

func (ErrDomain) Field

func (e ErrDomain) Field() string

Field returns the field where occurred the error

type ID

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

ID represents an valid ID

func NewID

func NewID(value uint64) *ID

NewID build a new ID struct

func (ID) Value

func (I ID) Value() uint64

Value returns the valid ID number

type Operation

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

Operation contains all data to recognize the type of a transaction

func NewOperation

func NewOperation(id *ID) (*Operation, error)

NewOperation creates a valid Operation struct

func (Operation) Description

func (o Operation) Description() string

Description returns the description value

func (Operation) ID

func (o Operation) ID() *ID

ID returns the id value

func (Operation) IsIncoming

func (o Operation) IsIncoming() bool

IsIncoming checks if the operation is an incoming operation

type Transaction

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

Transaction represents a Transaction in the Domain

func NewTransaction

func NewTransaction(accountID *ID, operationID *ID, amount float64) (*Transaction, error)

NewTransaction builds a new Transaction struct

func (*Transaction) Account

func (t *Transaction) Account() *Account

Account returns the account used to register the transaction

func (*Transaction) Amount

func (t *Transaction) Amount() float64

Amount returns the amount

func (*Transaction) CreatedAt

func (t *Transaction) CreatedAt() time.Time

CreatedAt returns the createdAt value

func (*Transaction) ID

func (t *Transaction) ID() *ID

ID returns the transaction's id

func (*Transaction) Operation

func (t *Transaction) Operation() *Operation

Operation returns the type of then operation of the transaction

func (*Transaction) Store

Store stores a transaction given a repository

func (*Transaction) WithAccount

func (t *Transaction) WithAccount(a *Account) *Transaction

WithAccount returns a new Transaction struct with the informed account

func (*Transaction) WithID

func (t *Transaction) WithID(id *ID) *Transaction

WithID returns a new Transaction struct with the informed account

type TransactionRepositoryWriter

type TransactionRepositoryWriter interface {
	Store(*Transaction) (*ID, error)
}

TransactionRepositoryWriter represents the behaviour of the Transaction Repository

type TransactionRepositoryWriterMock

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

TransactionRepositoryWriterMock is a fake representation of a TransactionRepositoryWriter, useful to create unit tests

func NewTransactionRepositoryMock

func NewTransactionRepositoryMock(id *ID, err error) *TransactionRepositoryWriterMock

NewTransactionRepositoryMock builds a new TransactionRepositoryWriterMock struct with its mock results

func (TransactionRepositoryWriterMock) Store

Store stores a transaction

Jump to

Keyboard shortcuts

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