handle dimension
This commit is contained in:
@ -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"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user