package models

import (
	"time"

	"github.com/golang-jwt/jwt/v5"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/mongo"
)

type Config struct {
	HTTP     ConfigurationHTTP
	GRPC     ConfigurationGRPC
	Service  ServiceConfiguration
	Database mongo.Configuration
}

type ConfigurationHTTP struct {
	Host string `env:"HTTP_HOST,default=localhost"`
	Port string `env:"HTTP_PORT,default=8080"`
}

type ConfigurationGRPC struct {
	Host  string `env:"GRPC_HOST,default=localhost"`
	Port  string `env:"GRPC_PORT,default=8081"`
	Domen string `env:"GRPC_DOMEN,default=https://domen.ru"`
}

type ServiceConfiguration struct {
	AuthMicroservice           AuthMicroserviceConfiguration
	HubadminMicroservice       HubadminMicroserviceConfiguration
	CurrencyMicroservice       CurrencyMicroserviceConfiguration
	DiscountMicroservice       DiscountMicroserviceConfiguration
	PaymentMicroservice        PaymentMicroserviceConfiguration
	VerificationMicroservice   VerificationMicroserviceConfiguration
	TemplategenMicroserviceURL TemplategenMicroserviceConfiguration
	JWT                        JWTConfiguration
	Kafka                      KafkaConfiguration
}

type KafkaConfiguration struct {
	Tariff  TariffKafkaConfiguration `json:"tariff"`
	Brokers []string                 `json:"brokers" env:"KAFKA_BROKERS,required"`
}

type TariffKafkaConfiguration struct {
	Topic string `json:"topic" env:"KAFKA_TOPIC_TARIFF,required"`
}

type JWTConfiguration struct {
	PrivateKey string `env:"JWT_PRIVATE_KEY"`
	PublicKey  string `env:"JWT_PUBLIC_KEY,required"`
	Issuer     string `env:"JWT_ISSUER,required"`
	Audience   string `env:"JWT_AUDIENCE,required"`
	Algorithm  jwt.SigningMethodRSA
	ExpiresIn  time.Duration
}

type AuthMicroserviceConfiguration struct {
	URL AuthMicroserviceURL
}

type HubadminMicroserviceConfiguration struct {
	URL HubadminMicroserviceURL
}

type CurrencyMicroserviceConfiguration struct {
	URL CurrencyMicroserviceURL
}

type VerificationMicroserviceConfiguration struct {
	URL VerificationMicroserviceURL
}

type TemplategenMicroserviceConfiguration struct {
	URL TemplategenMicroserviceURL
}

type PaymentMicroserviceConfiguration struct {
	HostGRPC string `env:"PAYMENT_MICROSERVICE_GRPC_HOST,required"`
}

type DiscountMicroserviceConfiguration struct {
	HostGRPC string `env:"DISCOUNT_MICROSERVICE_GRPC_HOST,required"`
}

type AuthMicroserviceURL struct {
	User string `env:"AUTH_MICROSERVICE_USER_URL,required"`
}

type HubadminMicroserviceURL struct {
	Tariff string `env:"HUBADMIN_MICROSERVICE_TARIFF_URL,required"`
}

type CurrencyMicroserviceURL struct {
	Translate string `env:"CURRENCY_MICROSERVICE_TRANSLATE_URL,required"`
}

type VerificationMicroserviceURL struct {
	Verification string `env:"VERIFICATION_MICROSERVICE_USER_URL,required"`
}

type TemplategenMicroserviceURL struct {
	Templategen string `env:"TEMPLATEGEN_MICROSERVICE_URL,required"`
}
