package config

// Config is a struct define configuration for the app
type Config struct {
	Stage       string            `mapstructure:"stage"`
	Logger      LoggerConfig      `mapstructure:"logger"`
	HTTP        HTTPServerConfig  `mapstructure:"http_server"`
	CallistoAPI CallistoAPIConfig `mapstructure:"callisto_api"`
	CallistoSO  CallistoSOConfig  `mapstructure:"callisto_so"`
}

// HTTPServerConfig is a struct to define configurations of the HTTP server
type HTTPServerConfig struct {
	IsEnabled         bool     `mapstructure:"enabled"`
	Host              string   `mapstructure:"host"`
	Port              int      `mapstructure:"port"`
	ReadHeaderTimeout int      `mapstructure:"read_header_timeout"`
	ApiPrefix         string   `mapstructure:"api_prefix"`
	AllowedOrigins    []string `mapstructure:"allowed_origins"`
	Proxy             Proxy    `mapstructure:"proxy"`
}

type Proxy struct {
	IsEnabled bool              `mapstructure:"enabled"`
	Paths     map[string]string `mapstructure:"paths"`
}

// LoggerConfig is a struct to define configurations for Logger
type LoggerConfig struct {
	LogOutput   string `mapstructure:"log_output_to"`
	ErrorOutput string `mapstructure:"log_errors_to"`
	Level       string `mapstructure:"log_level"`
}

// CallistoAPIConfig is a config to map the sale order endpoints on callisto api
type CallistoAPIConfig struct {
	Host      string       `mapstructure:"host"`
	SaleOrder SaleOrderAPI `mapstructure:"sale_order"`
	Bids      BidsAPI      `mapstructure:"bids"`
	Auth      AuthAPI      `mapstructure:"auth"`
}

// SaleOrderProxy is a config to map the create order url from callisto api
type SaleOrderAPI struct {
	Create string `mapstructure:"create_url"`
	Update string `mapstructure:"update_url"`
}

// BidsAPI is a config to map the bids url from callisto api
type BidsAPI struct {
	SetWinner string `mapstructure:"set_winner"`
}

// AuthAPI is a config to map the auth info from callisto api
type AuthAPI struct {
	Me string `mapstructure:"me"`
}

// CallistoSOConfig is the struct for Caallisto Sale order service backend
type CallistoSOConfig struct {
	Enabled bool                `mapstructure:"enabled"`
	Host    string              `mapstructure:"host"`
	Config  CallistoSORPCConfig `mapstructure:"config_rpc"`
}

type CallistoSORPCConfig struct {
	// FeatureFlag.IsEnabled true will enable send request to callisto-so
	// false will forward the request to proxy
	GetSOSummary FeatureFlag `mapstructure:"get_so_summary"`
}

type FeatureFlag struct {
	IsEnabled bool `mapstructure:"enabled"`
}
