diff --git a/code-generate/parse_main.go b/code-generate/parse_main.go index 0f615b07..b7bea03b 100644 --- a/code-generate/parse_main.go +++ b/code-generate/parse_main.go @@ -4,12 +4,17 @@ import ( yaml "gopkg.in/yaml.v2" ) +// XXX: using a global variable has a smell... however, its just a code +// generator, not production code +var traits yaml.MapSlice + func parseYaml(data yaml.MapSlice) (objects []RamlType, domains []ServiceDomain) { types := getPropertyValue(data, "types") for _, mapItem := range types.(yaml.MapSlice) { obj := createRamlType(mapItem.Key.(string), mapItem.Value.(yaml.MapSlice)) objects = append(objects, obj) } + traits = getPropertyValue(data, "traits").(yaml.MapSlice) domains = make([]ServiceDomain, 0) apiResources := getPropertyValue(data, "/{projectKey}") @@ -28,3 +33,12 @@ func parseYaml(data yaml.MapSlice) (objects []RamlType, domains []ServiceDomain) return } + +func getTrait(name string) yaml.MapSlice { + for _, t := range traits { + if t.Key == name { + return t.Value.(yaml.MapSlice) + } + } + return nil +} diff --git a/code-generate/parse_services.go b/code-generate/parse_services.go index 672a11dc..7c50af22 100644 --- a/code-generate/parse_services.go +++ b/code-generate/parse_services.go @@ -388,6 +388,31 @@ func parseResourceData(val yaml.MapSlice, method *ServiceMethod) { } } + for _, name := range method.Traits { + trait := getTrait(name) + if trait == nil { + continue + } + qparams := getPropertyValue(trait, "queryParameters") + if qparams != nil { + for _, item := range qparams.(yaml.MapSlice) { + obj := createRamlTypeAttribute(item.Key.(string), item.Value) + // traits are supposed to be optional + obj.Optional = true + exists := false + for _, existing := range method.QueryParameters { + if existing.Name == obj.Name { + exists = true + break + } + } + if !exists { + method.QueryParameters = append(method.QueryParameters, obj) + } + } + } + } + } func getTypeInformation(item yaml.MapItem) string { diff --git a/commercetools/service_in_store.go b/commercetools/service_in_store.go index d2885e31..bc5c589e 100644 --- a/commercetools/service_in_store.go +++ b/commercetools/service_in_store.go @@ -26,7 +26,8 @@ func (client *Client) StoreLogin(ctx context.Context, storeKey string, value *Cu // StoreShippingMethodsForMatchingCartInput is input for function StoreShippingMethodsForMatchingCart type StoreShippingMethodsForMatchingCartInput struct { - CartID string `url:"cartId"` + CartID string `url:"cartId"` + Expand []string `url:"expand,omitempty"` } // StoreShippingMethodsForMatchingCart for type StoreShippingMethodsForMatchingCartInput diff --git a/commercetools/service_product_projection.go b/commercetools/service_product_projection.go index 5f64d9af..92eecfcb 100644 --- a/commercetools/service_product_projection.go +++ b/commercetools/service_product_projection.go @@ -70,6 +70,16 @@ type ProductProjectionSearchInput struct { FuzzyLevel float64 `url:"fuzzyLevel,omitempty"` MarkMatchingVariants bool `url:"markMatchingVariants,omitempty"` Staged bool `url:"staged,omitempty"` + Limit float64 `url:"limit,omitempty"` + Offset float64 `url:"offset,omitempty"` + WithTotal bool `url:"withTotal,omitempty"` + LocaleProjection string `url:"localeProjection,omitempty"` + PriceChannel string `url:"priceChannel,omitempty"` + PriceCountry string `url:"priceCountry,omitempty"` + PriceCurrency string `url:"priceCurrency,omitempty"` + PriceCustomerGroup string `url:"priceCustomerGroup,omitempty"` + StoreProjection string `url:"storeProjection,omitempty"` + Expand []string `url:"expand,omitempty"` } /* @@ -97,6 +107,9 @@ type ProductProjectionSuggestInput struct { SearchKeywords map[string]string `url:"searchKeywords"` Fuzzy bool `url:"fuzzy,omitempty"` Staged bool `url:"staged,omitempty"` + Limit float64 `url:"limit,omitempty"` + Offset float64 `url:"offset,omitempty"` + WithTotal bool `url:"withTotal,omitempty"` } // ProductProjectionSuggest The source of data for suggestions is the searchKeyword field in a product diff --git a/commercetools/service_shipping_method.go b/commercetools/service_shipping_method.go index 4931cc55..8c74cbc2 100644 --- a/commercetools/service_shipping_method.go +++ b/commercetools/service_shipping_method.go @@ -168,7 +168,8 @@ func (client *Client) ShippingMethodUpdateWithKey(ctx context.Context, input *Sh // ShippingMethodMatchingCartInput is input for function ShippingMethodMatchingCart type ShippingMethodMatchingCartInput struct { - CartID string `url:"cartId"` + CartID string `url:"cartId"` + Expand []string `url:"expand,omitempty"` } // ShippingMethodMatchingCart Get ShippingMethods for a cart @@ -188,9 +189,10 @@ func (client *Client) ShippingMethodMatchingCart(ctx context.Context, value *Shi // ShippingMethodMatchingLocationInput is input for function ShippingMethodMatchingLocation type ShippingMethodMatchingLocationInput struct { - Country string `url:"country"` - Currency string `url:"currency,omitempty"` - State string `url:"state,omitempty"` + Country string `url:"country"` + Currency string `url:"currency,omitempty"` + State string `url:"state,omitempty"` + Expand []string `url:"expand,omitempty"` } // ShippingMethodMatchingLocation Get ShippingMethods for a location