lending

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type CreditScorer interface {
	GetScore(ctx context.Context, userID string) (int, error)
}

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.

type Status

type Status string

Status represents the state of a loan application.

const (
	StatusPending   Status = "PENDING"
	StatusApproved  Status = "APPROVED"
	StatusRejected  Status = "REJECTED"
	StatusDisbursed Status = "DISBURSED"
	StatusRepaid    Status = "REPAID"
)

Jump to

Keyboard shortcuts

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