package notification

import (
	"time"
)

// Config holds the notification service configuration
type Config struct {
	BaseURL       string        ``
	RetryAttempts int           ``
	Timeout       time.Duration ``
	RetryDelay    time.Duration ``
	EnableLogging bool          ``
	UserAgent     string        ``
}

// DefaultConfig returns default configuration for notification service
func DefaultConfig() *Config {
	return &Config{
		BaseURL:       "http://127.0.0.1:9095",
		Timeout:       30 * time.Second,
		RetryAttempts: 3,
		RetryDelay:    2 * time.Second,
		EnableLogging: true,
		UserAgent:     "TenderManagement-NotificationSDK/1.0",
	}
}

// NewConfig creates a new configuration for notification service
func NewConfig(baseURL string, timeout time.Duration, retryAttempts int, retryDelay time.Duration, enableLogging bool, userAgent string) *Config {
	return &Config{
		BaseURL:       baseURL,
		Timeout:       timeout,
		RetryAttempts: retryAttempts,
		RetryDelay:    retryDelay,
		EnableLogging: enableLogging,
		UserAgent:     userAgent,
	}
}

// Validate validates the configuration
func (c *Config) Validate() error {
	if c.BaseURL == "" {
		return ErrInvalidConfig{Field: "BaseURL", Message: "base URL cannot be empty"}
	}
	if c.Timeout <= 0 {
		return ErrInvalidConfig{Field: "Timeout", Message: "timeout must be positive"}
	}
	if c.RetryAttempts < 0 {
		return ErrInvalidConfig{Field: "RetryAttempts", Message: "retry attempts cannot be negative"}
	}
	if c.RetryDelay < 0 {
		return ErrInvalidConfig{Field: "RetryDelay", Message: "retry delay cannot be negative"}
	}
	return nil
}
