handle dimension

This commit is contained in:
2024-02-11 15:50:43 +03:00
parent 0c7e94c834
commit e072fcbef5
13 changed files with 479 additions and 27 deletions

View File

@ -8,6 +8,26 @@ import (
"unicode"
)
type GoodsItemSize struct {
Width Dimension
Height Dimension
Length Dimension
}
func (s GoodsItemSize) GetSum(kind DimensionKind) float64 {
var value float64
sum := func(ds ...Dimension) {
for _, d := range ds {
value += d.AdjustTo(kind).Value
}
}
sum(s.Height, s.Length, s.Length)
return value
}
type GoodsItem struct {
Articul string `json:"sku"`
PhotoURLs []string `json:"photo"`
@ -22,6 +42,7 @@ type GoodsItem struct {
TariffPrice float64 `json:"tariff_price"`
Cart int64 `json:"cart"`
Stock int `json:"stock"`
Sizes GoodsItemSize `json:"sizes"`
Parameters map[string]string `json:"parameters"`
CreatedAt time.Time `json:"created_at"`
}