|
@@ -2,9 +2,9 @@ package relation
|
|
|
|
|
|
import (
|
|
|
"github.com/gshopify/service-wrapper/model"
|
|
|
- "github.com/gshopify/service-wrapper/scalar"
|
|
|
"github.com/mailru/dbr"
|
|
|
"gshopper.com/gshopify/products/graphql/generated"
|
|
|
+ "gshopper.com/gshopify/products/graphql/helper"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -35,28 +35,20 @@ type ProductVariant struct {
|
|
|
|
|
|
func (v *ProductVariant) As() *generated.ProductVariant {
|
|
|
variant := generated.ProductVariant{
|
|
|
- AvailableForSale: v.ForSale,
|
|
|
- CurrentlyNotInStock: v.QuantityAvailable <= 0,
|
|
|
-
|
|
|
Image: nil, //TODO:
|
|
|
UnitPrice: nil, //TODO:
|
|
|
UnitPriceMeasurement: nil, //TODO:
|
|
|
|
|
|
- Price: &generated.MoneyV2{
|
|
|
- Amount: scalar.NewDecimal(v.Price),
|
|
|
- CurrencyCode: generated.CurrencyCodeUsd,
|
|
|
- },
|
|
|
- CompareAtPrice: &generated.MoneyV2{
|
|
|
- Amount: scalar.NewDecimal(v.CompareAtPrice),
|
|
|
- CurrencyCode: generated.CurrencyCodeUsd,
|
|
|
- },
|
|
|
-
|
|
|
- ID: model.NewId(model.GidVariant, v.Id),
|
|
|
- Product: &generated.Product{ID: model.NewId(model.GidProduct, v.ProductId)},
|
|
|
- QuantityAvailable: &v.QuantityAvailable,
|
|
|
- RequiresShipping: v.RequiresShipping,
|
|
|
- Title: v.Title,
|
|
|
- WeightUnit: generated.WeightUnit(v.WeightUnit),
|
|
|
+ ID: model.NewId(model.GidVariant, v.Id),
|
|
|
+ Product: &generated.Product{ID: model.NewId(model.GidProduct, v.ProductId)},
|
|
|
+ Price: helper.NewMoney(v.Price, generated.CurrencyCodeUsd),
|
|
|
+ CompareAtPrice: helper.NewMoney(v.CompareAtPrice, generated.CurrencyCodeUsd),
|
|
|
+ AvailableForSale: v.ForSale,
|
|
|
+ CurrentlyNotInStock: v.QuantityAvailable <= 0,
|
|
|
+ QuantityAvailable: &v.QuantityAvailable,
|
|
|
+ RequiresShipping: v.RequiresShipping,
|
|
|
+ Title: v.Title,
|
|
|
+ WeightUnit: generated.WeightUnit(v.WeightUnit),
|
|
|
}
|
|
|
|
|
|
variant.Metafields = append(variant.Metafields, &generated.Metafield{
|