Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidInput = errors.New("invalid input parameters") ErrApplicationNotFound = errors.New("loan application not found") ErrOfferExpired = errors.New("loan offer has expired") ErrCreditScoreTooLow = errors.New("credit score does not meet minimum requirements") ErrInternal = errors.New("internal system error") )
Common errors returned by the lending service.
Functions ¶
This section is empty.
Types ¶
type CreditScorer ¶
CreditScorer defines the interface for external credit scoring systems.
type LoanApplication ¶
type LoanApplication struct {
ID string `json:"id"`
UserID string `json:"user_id"`
AmountCents int64 `json:"amount_cents"`
Currency string `json:"currency"`
DurationMonths int `json:"duration_months"`
Purpose string `json:"purpose"`
Status Status `json:"status"`
InterestRate float64 `json:"interest_rate"` // Annual percentage
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
LoanApplication represents a user's request for funds.
type NotificationService ¶
type NotificationService interface {
Notify(ctx context.Context, userID string, message string) error
}
NotificationService defines the interface for sending alerts to users.
type Offer ¶
type Offer struct {
ID string `json:"id"`
UserID string `json:"user_id"`
MaxAmountCents int64 `json:"max_amount_cents"`
InterestRate float64 `json:"interest_rate"`
ValidUntil time.Time `json:"valid_until"`
Terms string `json:"terms"`
}
Offer represents a pre-approved loan offer presented to the user.
type Repository ¶
type Repository interface {
SaveApplication(ctx context.Context, app *LoanApplication) error
GetApplicationByID(ctx context.Context, id string) (*LoanApplication, error)
UpdateApplicationStatus(ctx context.Context, id string, status Status) error
GetActiveOffers(ctx context.Context, userID string) ([]Offer, error)
SaveOffer(ctx context.Context, offer *Offer) error
}
Repository defines the data persistence layer requirements.
type Service ¶
type Service interface {
ApplyForLoan(ctx context.Context, userID string, amountCents int64, durationMonths int, purpose string) (*LoanApplication, error)
GetPreApprovedOffers(ctx context.Context, userID string) ([]Offer, error)
AcceptOffer(ctx context.Context, userID string, offerID string, amountCents int64) (*LoanApplication, error)
}
Service defines the public API for the lending domain.
func NewService ¶
func NewService(repo Repository, scorer CreditScorer, notifier NotificationService) Service
NewService creates a new instance of the lending service.