money.go 535 B

1234567891011121314151617181920
  1. package helper
  2. import (
  3. "github.com/gshopify/service-wrapper/scalar"
  4. "gshopper.com/gshopify/products/graphql/generated"
  5. )
  6. func NewPriceRange(min, max float64, currency generated.CurrencyCode) *generated.ProductPriceRange {
  7. return &generated.ProductPriceRange{
  8. MaxVariantPrice: NewMoney(max, currency),
  9. MinVariantPrice: NewMoney(min, currency),
  10. }
  11. }
  12. func NewMoney(f float64, currency generated.CurrencyCode) *generated.MoneyV2 {
  13. return &generated.MoneyV2{
  14. Amount: scalar.NewDecimal(f),
  15. CurrencyCode: currency,
  16. }
  17. }