package mapping

import (
	proto "sipro-mps/api/generated/v1/wb/products"
	internal "sipro-mps/pkg/api/wb/client"
	wbclient "sipro-mps/pkg/api/wb/client"
)

//go:generate go run github.com/jmattheis/goverter/cmd/goverter gen .

// goverter:converter
// goverter:extend  OptIntToInt64 OptStringToString WbDimensionsToProto
// goverter:ignoreUnexported yes
// goverter:matchIgnoreCase yes
type Converter interface {
	ToProto(details *internal.ContentV2GetCardsListPostOKCardsItem) *proto.Product
}

func OptIntToInt64(i wbclient.OptInt) int64 {
	return int64(i.Value)
}
func OptStringToString(s wbclient.OptString) string {
	return s.Value
}
func WbDimensionsToProto(s wbclient.OptContentV2GetCardsListPostOKCardsItemDimensions) *proto.Product_Dimensions {
	result := proto.Product_Dimensions{}
	if !s.Set {
		return &result
	}
	value := s.Value
	result.Length = int64(value.Length.Value)
	result.Width = int64(value.Width.Value)
	result.WeightBrutto = float32(value.WeightBrutto.Value)
	result.IsValid = value.IsValid.Value
	return &result
}
