Documentation ¶
Index ¶
- Constants
- Variables
- type Account
- type AccountListItem
- type Config
- type EventTranfserIncoming
- type EventTranfserOutgoing
- type FindByIbanAndOwnerOpts
- type FindByIdOpts
- type FindByUserIdAndIdOpts
- type ListByUserIdOpts
- type Repo
- type SaveOpts
- type Status
- type Transaction
- type TransactionConfig
- type TransactionDirection
- type TransactionFilterOpts
- type TransactionFilters
- type TransactionKind
- type TransactionListItem
- type TransactionRepo
- type TransactionSaveOpts
Constants ¶
View Source
const ( SubjectTransferIncoming = "Account.TransferIncoming" SubjectTransferOutgoing = "Account.TransferOutgoing" )
Variables ¶
View Source
var ( NotAvailable = rescode.New(4000, http.StatusForbidden, codes.Unavailable, "not_available", rescode.R{ "isNotAvailable": true, }) BalanceInsufficient = rescode.New(4001, http.StatusForbidden, codes.Unavailable, "balance_insufficient", rescode.R{ "isBalanceInsufficient": true, }) NotFound = rescode.New(4002, http.StatusNotFound, codes.NotFound, "not_found", rescode.R{ "isNotFound": true, }) ToAccNotAvailable = rescode.New(4003, http.StatusForbidden, codes.Unavailable, "to_acc_not_available", rescode.R{ "isToAccNotAvailable": true, }) TransferToSameAccount = rescode.New(4004, http.StatusForbidden, codes.Unavailable, "transfer_to_same_account", rescode.R{ "isTransferToSameAccount": true, }) CurrencyMismatch = rescode.New(4005, http.StatusForbidden, codes.Unavailable, "currency_mismatch", rescode.R{ "isCurrencyMismatch": true, }) )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID uuid.UUID `json:"id"` UserId uuid.UUID `json:"user_id"` Name string `json:"name"` Owner string `json:"owner"` Iban string `json:"iban"` // ISO 4217 currency code Currency string `json:"currency" example:"EUR"` Status Status `json:"status"` Balance decimal.Decimal `json:"balance"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt time.Time `json:"deleted_at"` }
func (*Account) IsAvailable ¶
type AccountListItem ¶
type EventTranfserIncoming ¶
type EventTranfserOutgoing ¶
type FindByIbanAndOwnerOpts ¶
type FindByIdOpts ¶
type FindByUserIdAndIdOpts ¶
type ListByUserIdOpts ¶
type ListByUserIdOpts struct { UserId uuid.UUID `example:"550e8400-e29b-41d4-a716-446655440000"` Pagi *list.PagiRequest }
type Repo ¶
type Repo interface { txadapter.Repo Save(ctx context.Context, t trace.Tracer, opts SaveOpts) error ListByUserId(ctx context.Context, t trace.Tracer, opts ListByUserIdOpts) (*list.PagiResponse[*Account], error) FindByIbanAndOwner(ctx context.Context, t trace.Tracer, opts FindByIbanAndOwnerOpts) (*Account, error) FindByUserIdAndId(ctx context.Context, t trace.Tracer, opts FindByUserIdAndIdOpts) (*Account, error) FindById(ctx context.Context, t trace.Tracer, opts FindByIdOpts) (*Account, error) }
type Transaction ¶
type Transaction struct { ID uuid.UUID `json:"id"` SenderId uuid.UUID `json:"sender_id"` ReceiverId uuid.UUID `json:"receiver_id"` Amount decimal.Decimal `json:"amount"` Description string `json:"description"` Kind TransactionKind `json:"kind"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt time.Time `json:"deleted_at"` }
func NewTransaction ¶
func NewTransaction(cnf TransactionConfig) *Transaction
func (*Transaction) IsItself ¶
func (t *Transaction) IsItself() bool
func (*Transaction) IsUserReceiver ¶
func (t *Transaction) IsUserReceiver(userId uuid.UUID) bool
func (*Transaction) IsUserSender ¶
func (t *Transaction) IsUserSender(userId uuid.UUID) bool
type TransactionConfig ¶
type TransactionDirection ¶
type TransactionDirection string
const ( TransactionDirectionIncoming TransactionDirection = "incoming" TransactionDirectionOutgoing TransactionDirection = "outgoing" TransactionDirectionInternal TransactionDirection = "internal" )
func (TransactionDirection) String ¶
func (td TransactionDirection) String() string
type TransactionFilterOpts ¶
type TransactionFilterOpts struct { AccountId uuid.UUID `example:"550e8400-e29b-41d4-a716-446655440000"` Pagi *list.PagiRequest Filters *TransactionFilters }
type TransactionFilters ¶
type TransactionFilters struct { StartDate string `json:"start_date" query:"start_date" validate:"omitempty,datetime=2006-01-02"` EndDate string `json:"end_date" query:"end_date" validate:"omitempty,datetime=2006-01-02"` Kind string `json:"kind" query:"kind" validate:"omitempty,oneof=withdrawal deposit transfer fee"` }
type TransactionKind ¶
type TransactionKind string
const ( TransactionKindWithdrawal TransactionKind = "withdrawal" TransactionKindDeposit TransactionKind = "deposit" TransactionKindTransfer TransactionKind = "transfer" TransactionKindFee TransactionKind = "fee" )
func (TransactionKind) String ¶
func (tk TransactionKind) String() string
type TransactionListItem ¶
type TransactionListItem struct { ID uuid.UUID `json:"id"` AccountId *uuid.UUID `json:"account_id,omitempty"` AccountName *string `json:"account_name,omitempty"` Amount string `json:"amount"` Description string `json:"description"` Kind string `json:"kind"` Direction string `json:"direction"` CreatedAt string `json:"created_at"` }
type TransactionRepo ¶
type TransactionRepo interface { txadapter.Repo Save(ctx context.Context, t trace.Tracer, opts TransactionSaveOpts) error Filter(ctx context.Context, t trace.Tracer, opts TransactionFilterOpts) (*list.PagiResponse[*Transaction], error) }
type TransactionSaveOpts ¶
type TransactionSaveOpts struct {
Transaction *Transaction `example:"{}"`
}
Click to show internal directories.
Click to hide internal directories.