Version: v0.0.0-...-401f45e Latest Latest

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

Go to latest
Published: Nov 25, 2018 License: Apache-2.0 Imports: 1 Imported by: 0



Package domain provides core business logic which is independent of any other systems and repositories



This section is empty.


View Source
var ErrAmountTooHigh = AmountTooHighStruct{errors.New("amount_too_high"), maximumAmountForFirstLoan}

ErrAmountTooHigh is returned when Client applied for a loan with excessive amount

View Source
var ErrClientAlreadyHasLoan = errors.New("client_already_has_loan")

ErrClientAlreadyHasLoan is returned when Client already has active (unpaid) loan

View Source
var ErrRepaymentAmountTooHigh = errors.New("repayment_amount_too_high")

ErrRepaymentAmountTooHigh is returned when Client tried to repay more than remaining amount of a loan


This section is empty.


type AmountTooHighStruct

type AmountTooHighStruct struct {
	MaxAmount int
	// contains filtered or unexported fields

AmountTooHighStruct is an error struct used by ErrAmountTooHigh with additional MaxAmount field indicating the maximum amount of a loan

type Client

type Client interface {
	PersonalNumber() string
	FirstName() string
	LastName() string
	ApplyForLoan(amount uint, term Term) (err error)
	HasActiveLoan() bool
	ActiveLoan() Loan
	Repay(amount uint) (err error)

Client can only have one active loan

func NewClient

func NewClient(firstName, lastName, personalNumber string) Client

NewClient returns Client instance

type Loan

type Loan interface {
	Amount() uint
	Term() Term
	Remaining() uint

Loan should be repaid in a given term or something bad will happen

type Term

type Term uint

Term is a number of days for which a loan was taken

Source Files

Jump to

Keyboard shortcuts

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