package tncservice

import (
	"sync"

	"bitbucket.org/nemt/nemt-portal-api/application/entitymapping"
	"bitbucket.org/nemt/nemt-portal-api/application/notificationservice"
	"bitbucket.org/nemt/nemt-portal-api/domain/service"
	"bitbucket.org/nemt/nemt-portal-api/infra/config"
)

var (
	instance *Service
	once     sync.Once
)

// Service holds the domain service repositories
type Service struct {
	Lyft     *lyftService
	LyftProd *lyftService
}

// New returns a new domain Service instance
func New(svc *service.Service, mapper *entitymapping.Mapper, cfg *config.Config, notificationService *notificationservice.Service) *Service {
	once.Do(func() {
		instance = &Service{
			Lyft:     newLyftService(svc, mapper, cfg, notificationService),
			LyftProd: newLyftProdService(svc, mapper, cfg, notificationService),
		}
	})

	return instance
}
