package service

import (
	"apskel-pos-be/internal/models"
	"apskel-pos-be/internal/processor"
	"context"

	"github.com/google/uuid"
)

type OutletSettingService interface {
	CreateSetting(ctx context.Context, req *models.CreateOutletSettingRequest) (*models.OutletSettingResponse, error)
	UpdateSetting(ctx context.Context, outletID uuid.UUID, key string, req *models.UpdateOutletSettingRequest) (*models.OutletSettingResponse, error)
	GetSetting(ctx context.Context, outletID uuid.UUID, key string) (*models.OutletSettingResponse, error)
	GetPrinterSettings(ctx context.Context, outletID uuid.UUID) (*models.OutletPrinterSettings, error)
	UpdatePrinterSettings(ctx context.Context, outletID uuid.UUID, req *models.UpdateOutletPrinterSettingsRequest) (*models.OutletPrinterSettings, error)
	DeleteSetting(ctx context.Context, outletID uuid.UUID, key string) error
}

type OutletSettingServiceImpl struct {
	outletSettingProcessor *processor.OutletSettingProcessorImpl
}

func NewOutletSettingService(outletSettingProcessor *processor.OutletSettingProcessorImpl) OutletSettingService {
	return &OutletSettingServiceImpl{
		outletSettingProcessor: outletSettingProcessor,
	}
}

func (s *OutletSettingServiceImpl) CreateSetting(ctx context.Context, req *models.CreateOutletSettingRequest) (*models.OutletSettingResponse, error) {
	return s.outletSettingProcessor.CreateSetting(ctx, req)
}

func (s *OutletSettingServiceImpl) UpdateSetting(ctx context.Context, outletID uuid.UUID, key string, req *models.UpdateOutletSettingRequest) (*models.OutletSettingResponse, error) {
	return s.outletSettingProcessor.UpdateSetting(ctx, outletID, key, req)
}

func (s *OutletSettingServiceImpl) GetSetting(ctx context.Context, outletID uuid.UUID, key string) (*models.OutletSettingResponse, error) {
	return s.outletSettingProcessor.GetSetting(ctx, outletID, key)
}

func (s *OutletSettingServiceImpl) GetPrinterSettings(ctx context.Context, outletID uuid.UUID) (*models.OutletPrinterSettings, error) {
	return s.outletSettingProcessor.GetPrinterSettings(ctx, outletID)
}

func (s *OutletSettingServiceImpl) UpdatePrinterSettings(ctx context.Context, outletID uuid.UUID, req *models.UpdateOutletPrinterSettingsRequest) (*models.OutletPrinterSettings, error) {
	return s.outletSettingProcessor.UpdatePrinterSettings(ctx, outletID, req)
}

func (s *OutletSettingServiceImpl) DeleteSetting(ctx context.Context, outletID uuid.UUID, key string) error {
	return s.outletSettingProcessor.DeleteSetting(ctx, outletID, key)
}
