Documentation ¶
Index ¶
- Variables
- type Subscription
- type Transaction
- func (t *Transaction) Build() *Transaction
- func (t *Transaction) GetIdempontencyKey() string
- func (t *Transaction) GetNext() string
- func (t *Transaction) SetCreatedAt(date string)
- func (t *Transaction) SetID(id string)
- func (t *Transaction) SetIdempontencyKey(key string)
- func (t *Transaction) SetNext(next string)
- func (t *Transaction) ValidateAmount() error
- func (t *Transaction) ValidateIdempotency(err error) error
- func (t *Transaction) ValidateUserID(key string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDataNotFound is the error returned when the data is not found ErrDataNotFound = errors.New("data not found") // ErrInvalidData is the error returned when the data is invalid ErrInvalidData = errors.New("invalid data") // ErrInvalidPagination is the error returned when the pagination is invalid ErrInvalidPagination = errors.New("invalid pagination") // ErrInvalidUser is the error returned when the user is invalid ErrInvalidUser = errors.New("invalid user") // ErrInvalidAmount is the error returned when the amount is invalid ErrInvalidAmount = errors.New("invalid amount") // ErrDataAlreadyExists is the error returned when the data already exists ErrDataAlreadyExists = errors.New("data already exists") )
Functions ¶
This section is empty.
Types ¶
type Subscription ¶
type Subscription struct { Topic string `json:"-"` Protocol string `json:"protocol" binding:"required,oneof=email"` Endpoint string `json:"endpoint" binding:"required"` }
Subscription represents a subscription to a topic
type Transaction ¶
type Transaction struct { User struct { ID string `json:"id" binding:"required"` } `json:"user" binding:"required"` ID string `json:"id"` Currency string `json:"currency" binding:"required"` Origin string `json:"origin" binding:"required"` OperationType string `json:"operationType" binding:"required,oneof=debit credit"` CreatedAt string `json:"createdAt"` Amount float64 `json:"amount" binding:"required"` // contains filtered or unexported fields }
Transaction represents a transaction domain model holds the business logic and functions to be used by the application to validate and manipulate the data
func (*Transaction) Build ¶
func (t *Transaction) Build() *Transaction
Build sets default values for a transaction
func (*Transaction) GetIdempontencyKey ¶
func (t *Transaction) GetIdempontencyKey() string
GetIdempontencyKey gets the idempontency key for a transaction
func (*Transaction) GetNext ¶
func (t *Transaction) GetNext() string
GetNext gets the next token for a paginated response
func (*Transaction) SetCreatedAt ¶
func (t *Transaction) SetCreatedAt(date string)
SetCreatedAt sets the created at field for a transaction
func (*Transaction) SetID ¶
func (t *Transaction) SetID(id string)
SetID sets the id for a transaction
func (*Transaction) SetIdempontencyKey ¶
func (t *Transaction) SetIdempontencyKey(key string)
SetIdempontencyKey sets the idempontency key for a transaction
func (*Transaction) SetNext ¶
func (t *Transaction) SetNext(next string)
SetNext sets the next token for a paginated response
func (*Transaction) ValidateAmount ¶
func (t *Transaction) ValidateAmount() error
ValidateAmount validates if a transaction has a valid amount
func (*Transaction) ValidateIdempotency ¶
func (t *Transaction) ValidateIdempotency(err error) error
ValidateIdempotency validates if a transaction is idempotent the logic is just to handle which error should be returned
func (*Transaction) ValidateUserID ¶
func (t *Transaction) ValidateUserID(key string) error
ValidateUserID validates if a transaction has a valid user id the logic is just to handle which error should be returned