package location

import (
	"context"

	"github.com/UpmeshLTD/urus-aio/infrastructure/db/entities"
)

type Service interface {
	GetCountries(ctx context.Context) ([]*entities.Country, error)
	GetCountryByID(ctx context.Context, countryID int64) (*entities.Country, error)
	GetCountryByCode(ctx context.Context, countryCode string) (*entities.Country, error)
	GetLocations(ctx context.Context, params *entities.GetLocationsFilterParams) ([]*entities.Location, error)
}

type serviceImpl struct {
	repo Repository
}

func NewService(repo Repository) Service {
	return &serviceImpl{
		repo: repo,
	}
}

func (s *serviceImpl) GetCountries(ctx context.Context) ([]*entities.Country, error) {
	return s.repo.GetCountries(ctx)
}

func (s *serviceImpl) GetCountryByID(ctx context.Context, countryID int64) (*entities.Country, error) {
	return s.repo.GetCountryByID(ctx, countryID)
}

func (s *serviceImpl) GetCountryByCode(ctx context.Context, countryCode string) (*entities.Country, error) {
	return s.repo.GetCountryByCode(ctx, countryCode)
}

func (s *serviceImpl) GetLocations(ctx context.Context, params *entities.GetLocationsFilterParams) ([]*entities.Location, error) {
	return s.repo.GetLocations(ctx, params)
}
