refactor: Add ExchangeRateService interface and format currency types with consistent alignment

- Add ExchangeRateService interface with GetExchangeRate, ConvertAmount, GetRateHistory, UpdateExchangeRate, GetSupportedCurrencies, ValidateCurrencyPair, and RefreshRates methods
- Add CurrencyRevenue struct with currency and revenue fields
- Add TransactionTypeStats struct with type, count, amount, and currency fields
- Align struct field tags consistently across Currency, ExchangeRate, Transaction, and request/response types
This commit is contained in:
nutcas3
2026-05-02 01:22:37 +03:00
parent 295649bcea
commit a31344714e
2 changed files with 108 additions and 83 deletions
@@ -39,6 +39,17 @@ type ExchangeRateProvider interface {
RefreshRates(ctx context.Context) error RefreshRates(ctx context.Context) error
} }
// ExchangeRateService defines the interface for exchange rate operations
type ExchangeRateService interface {
GetExchangeRate(ctx context.Context, fromCurrency, toCurrency string) (*ExchangeRate, error)
ConvertAmount(ctx context.Context, amount float64, fromCurrency, toCurrency string) (*CurrencyConversionResponse, error)
GetRateHistory(ctx context.Context, fromCurrency, toCurrency string, days int) ([]*ExchangeRate, error)
UpdateExchangeRate(ctx context.Context, rate *ExchangeRate) error
GetSupportedCurrencies(ctx context.Context) ([]*Currency, error)
ValidateCurrencyPair(ctx context.Context, fromCurrency, toCurrency string) error
RefreshRates(ctx context.Context) error
}
// BillingService defines the interface for multi-currency billing operations // BillingService defines the interface for multi-currency billing operations
type BillingService interface { type BillingService interface {
ProcessBilling(ctx context.Context, req *BillingRequest) (*BillingResponse, error) ProcessBilling(ctx context.Context, req *BillingRequest) (*BillingResponse, error)
@@ -147,3 +147,17 @@ type BillingResponse struct {
Status string `json:"status"` Status string `json:"status"`
ProcessedAt time.Time `json:"processed_at"` ProcessedAt time.Time `json:"processed_at"`
} }
// CurrencyRevenue represents revenue for a specific currency
type CurrencyRevenue struct {
Currency string `json:"currency"`
Revenue float64 `json:"revenue"`
}
// TransactionTypeStats represents statistics for a transaction type
type TransactionTypeStats struct {
Type TransactionType `json:"type"`
Count int `json:"count"`
Amount float64 `json:"amount"`
Currency string `json:"currency"`
}