package delivery_plan

import (
	"context"

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

type Service interface {
	GetDeliveryPlans(ctx context.Context, params *entities.GetDeliveryPlansFilterParams) ([]*entities.CourierDeliveryPlan, error)
	CreateDeliveryPlan(ctx context.Context, entity *entities.CourierDeliveryPlan) (*entities.CourierDeliveryPlan, error)
	UpdateDeliveryPlan(ctx context.Context, id entities.ID, entity *entities.CourierDeliveryPlan) error
	DeleteDeliveryPlan(ctx context.Context, id entities.ID) error
}

type serviceImpl struct {
	repo Repository
}

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

func (s *serviceImpl) GetDeliveryPlans(ctx context.Context, params *entities.GetDeliveryPlansFilterParams) ([]*entities.CourierDeliveryPlan, error) {
	return s.repo.GetDeliveryPlans(ctx, params)
}

func (s *serviceImpl) CreateDeliveryPlan(ctx context.Context, entity *entities.CourierDeliveryPlan) (*entities.CourierDeliveryPlan, error) {
	return s.repo.CreateDeliveryPlan(ctx, entity)
}

func (s *serviceImpl) UpdateDeliveryPlan(ctx context.Context, id entities.ID, entity *entities.CourierDeliveryPlan) error {
	return s.repo.UpdateDeliveryPlan(ctx, id, entity)
}

func (s *serviceImpl) DeleteDeliveryPlan(ctx context.Context, id entities.ID) error {
	return s.repo.DeleteDeliveryPlan(ctx, id)
}
