card

package
v0.0.0-...-984c388 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = exception.ResourceNotFound{Resource: "card"}
	ErrInvalidCardType = exception.InvalidParameter{
		Field:       "card",
		ValidValues: "CREDIT,DEBIT",
	}
	ErrCreditWithAccount = exception.DomainGeneric{
		Code:   "InvalidCreditCard",
		Parent: errors.New("credit cards are not allowed to attach financial accounts"),
	}
)

Functions

This section is empty.

Types

type Card

type Card struct {
	ID               string
	User             user.User                          // req, FK -> users
	FinancialAccount *financialaccount.FinancialAccount // FK -> financial_accounts (nullable on credit cards)
	DisplayName      string                             // req
	BankName         string
	LastDigits       uint16
	CardType         TypeCard // enum: credit/debit, req
	Balance          float64  // nullable
	BalanceLimit     float64  // nullable
	CurrencyCode     string
	customtype.Auditable
}

Card financial instrument issued by a financial institution as component for interactions between a User and either a FinancialAccount or credit line.

type CreateCommand

type CreateCommand struct {
	OwnerID            string `json:"owner_id" validate:"required"`
	FinancialAccountID string `json:"financial_account_id"`
	CardType           string `json:"card_type" validate:"required,oneof=CREDIT DEBIT"`
	// contains filtered or unexported fields
}

type Repository

type Repository interface {
	storage.Repository[Card]
	GetUserCards(ctx context.Context, cr storage.Criteria, userID string) ([]Card, storage.PageToken, error)
}

type Service

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

func NewService

func NewService(r Repository, accRepo financialaccount.Repository) Service

func (Service) Create

func (s Service) Create(ctx context.Context, args any) error

func (Service) Delete

func (s Service) Delete(ctx context.Context, id string) error

func (Service) GetByID

func (s Service) GetByID(ctx context.Context, id string) (View, error)

func (Service) List

func (Service) ListUserCards

func (s Service) ListUserCards(ctx context.Context, cr storage.Criteria, userID string) ([]View, storage.PageToken, error)

func (Service) Update

func (s Service) Update(ctx context.Context, args any) error

type TypeCard

type TypeCard uint8

func NewTypeCard

func NewTypeCard(v string) TypeCard

func NewTypeCardSafe

func NewTypeCardSafe(v string) (TypeCard, error)

func (TypeCard) IsCredit

func (c TypeCard) IsCredit() bool

func (TypeCard) IsDebit

func (c TypeCard) IsDebit() bool

func (TypeCard) String

func (c TypeCard) String() string

type UpdateCommand

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

type View

type View struct {
	ID               string                 `json:"card_id"`
	User             *user.View             `json:"user"`
	FinancialAccount *financialaccount.View `json:"financial_account"`
	DisplayName      string                 `json:"display_name"`
	BankName         *string                `json:"bank_name"`
	LastDigits       *uint16                `json:"last_digits"`
	CardType         string                 `json:"card_type"`
	Balance          float64                `json:"balance"`
	BalanceLimit     *float64               `json:"balance_limit"`
	CurrencyCode     string                 `json:"currency_code"`
	customtype.Auditable
}

func NewView

func NewView(c Card) View

Jump to

Keyboard shortcuts

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