Documentation
¶
Index ¶
- Variables
- type Account
- type AccountRepositoryMock
- type AccountRepositoryReader
- type AccountRepositoryWriter
- type Document
- type DocumentNumber
- type ErrDomain
- type ID
- type Operation
- type Transaction
- func (t *Transaction) Account() *Account
- func (t *Transaction) Amount() float64
- func (t *Transaction) CreatedAt() time.Time
- func (t *Transaction) ID() *ID
- func (t *Transaction) Operation() *Operation
- func (t *Transaction) Store(repo TransactionRepositoryWriter) (*Transaction, error)
- func (t *Transaction) WithAccount(a *Account) *Transaction
- func (t *Transaction) WithID(id *ID) *Transaction
- type TransactionRepositoryWriter
- type TransactionRepositoryWriterMock
Constants ¶
This section is empty.
Variables ¶
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) Store ¶
func (a *Account) Store(repo AccountRepositoryWriter) (*Account, error)
Store stores an account given a Repository
func (*Account) WithCreateAt ¶
WithCreateAt returns a new Account struct with the informed createAt 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
type AccountRepositoryReader ¶
AccountRepositoryReader represents the behaviour of the Account Repository to read operation
type AccountRepositoryWriter ¶
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 ¶
NewErrDomain build a new ErrDomain struct
func (ErrDomain) Description ¶
Description returns the description of the error
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation contains all data to recognize the type of a transaction
func NewOperation ¶
NewOperation creates a valid Operation struct
func (Operation) Description ¶
Description returns the description value
func (Operation) IsIncoming ¶
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) CreatedAt ¶
func (t *Transaction) CreatedAt() time.Time
CreatedAt returns the createdAt value
func (*Transaction) Operation ¶
func (t *Transaction) Operation() *Operation
Operation returns the type of then operation of the transaction
func (*Transaction) Store ¶
func (t *Transaction) Store(repo TransactionRepositoryWriter) (*Transaction, error)
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 ¶
func (t TransactionRepositoryWriterMock) Store(_ *Transaction) (*ID, error)
Store stores a transaction