package services

import (
	"sync"

	vconfig "github.com/fiskerinc/cloud-services/pkg/vehicleconfig"
)

var (
	sapService vconfig.SAPServiceInterface
	sapOnce    sync.Once
)

func GetSapService() vconfig.SAPServiceInterface {
	sapOnce.Do(func() {
		if sapService != nil {
			return
		}
		sapService = vconfig.NewSAPService()
	})

	return sapService
}

// SetSapService is supposed t be used for testing.
func SetSapService(sap vconfig.SAPServiceInterface) {
	sapService = sap
}
