package config

// ProviderMock is the dev/test email/SMS provider name.
const ProviderMock = "mock"

// Config is notification module settings (embedded in gateway root config).
type Config struct {
	DefaultLocale string              `json:",optional"`
	Async         AsyncConfig         `json:",optional"`
	RatePerTenant RatePerTenantConfig `json:",optional"`
	Email         EmailConfig         `json:",optional"`
	SMS           SMSConfig           `json:",optional"`
	Push          PushConfig          `json:",optional"`
	Webhook       WebhookConfig       `json:",optional"`
}

type AsyncConfig struct {
	QueueRedisKey  string `json:",optional"`
	Worker         int    `json:",optional"`
	MaxRetry       int    `json:",optional"`
	BackoffSeconds []int  `json:",optional"`
}

type RatePerTenantConfig struct {
	Email int `json:",optional"`
	SMS   int `json:",optional"`
}

type EmailConfig struct {
	Provider string               `json:",optional"`
	From     string               `json:",optional"`
	APIKey   string               `json:",optional"`
	SMTP     SMTPProviderSettings `json:",optional"`
	SES      SESProviderSettings  `json:",optional"`
}

// SMTPProviderSettings mirrors app-cloudep-notification-service SMTPConfig.
type SMTPProviderSettings struct {
	Enable   bool   `json:",optional"`
	Sort     int    `json:",optional"`
	Host     string `json:",optional"`
	Port     int    `json:",optional"`
	Username string `json:",optional"`
	Password string `json:",optional"`
}

// SESProviderSettings mirrors app-cloudep-notification-service AmazonSesSettings.
type SESProviderSettings struct {
	Enable       bool   `json:",optional"`
	Sort         int    `json:",optional"`
	Region       string `json:",optional"`
	AccessKey    string `json:",optional"`
	SecretKey    string `json:",optional"`
	SessionToken string `json:",optional"`
}

type SMSConfig struct {
	Provider   string                 `json:",optional"`
	AccountSID string                 `json:",optional"`
	AuthToken  string                 `json:",optional"`
	From       string                 `json:",optional"`
	Mitake     MitakeProviderSettings `json:",optional"`
}

// MitakeProviderSettings mirrors app-cloudep-notification-service MitakeSMSSender (三竹簡訊).
type MitakeProviderSettings struct {
	Enable   bool   `json:",optional"`
	Sort     int    `json:",optional"`
	User     string `json:",optional"`
	Password string `json:",optional"`
}

type PushConfig struct {
	Enabled bool `json:",optional"`
}

type WebhookConfig struct {
	HMACSecret string `json:",optional"`
}
