package initialize

import (
	"go.mongodb.org/mongo-driver/mongo"
	"go.uber.org/zap"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/repository"
)

type RepositoriesDeps struct {
	Logger  *zap.Logger
	MongoDB *mongo.Database
}

type Repositories struct {
	HealthRepository   *repository.HealthRepository
	AccountRepository  *repository.AccountRepository
	CurrencyRepository *repository.CurrencyRepository
	HistoryRepository  *repository.HistoryRepository
}

func NewRepositories(deps RepositoriesDeps) *Repositories {
	return &Repositories{
		HealthRepository: repository.NewHealthRepository(deps.MongoDB),
		AccountRepository: repository.NewAccountRepository(repository.AccountRepositoryDeps{
			Logger:  deps.Logger,
			MongoDB: deps.MongoDB.Collection("accounts"),
		}),
		CurrencyRepository: repository.NewCurrencyRepository(repository.CurrencyRepositoryDeps{
			Logger:  deps.Logger,
			MongoDB: deps.MongoDB.Collection("currency_lists"),
		}),
		HistoryRepository: repository.NewHistoryRepository(repository.HistoryRepositoryDeps{
			Logger:  deps.Logger,
			MongoDB: deps.MongoDB.Collection("histories"),
		}),
	}
}
