package prmap

import (
	"github.com/tech/sendico/payments/orchestrator/internal/service/orchestrationv2/agg"

	"github.com/tech/sendico/pkg/mlogger"
	orchestrationv2 "github.com/tech/sendico/pkg/proto/payments/orchestration/v2"
	"go.uber.org/zap"
)

// Mapper transforms orchestration-v2 runtime aggregate snapshots into API responses.
type Mapper interface {
	Map(in MapInput) (*MapOutput, error)
}

// MapInput is the mapper payload.
type MapInput struct {
	Payment *agg.Payment
}

// MapOutput is the mapper result.
type MapOutput struct {
	Payment *orchestrationv2.Payment
}

// Dependencies configures payment mapper integrations.
type Dependencies struct {
	Logger mlogger.Logger
}

func New(deps ...Dependencies) Mapper {
	var dep Dependencies
	if len(deps) > 0 {
		dep = deps[0]
	}
	logger := dep.Logger
	if logger == nil {
		logger = zap.NewNop()
	}
	return &svc{logger: logger.Named("mapper")}
}
