Class: AboutYou::SDK::Criteria::ProductFields
- Inherits:
-
Object
- Object
- AboutYou::SDK::Criteria::ProductFields
- Defined in:
- lib/AboutYou/Criteria/product_fields.rb
Overview
This class is used for the selection of certain product fields which should be fetched in addition when making an api call
- author
-
Collins GmbH & Co KG
Constant Summary collapse
- IS_ACTIVE =
id and name is set per default product field “is_active”
'active'- BRAND =
product field “brand_id”
'brand_id'- DESCRIPTION_LONG =
product field “description_long”
'description_long'- DESCRIPTION_SHORT =
product field “description_short”
'description_short'- DEFAULT_VARIANT =
product field “default_variant”
'default_variant'- VARIANTS =
product field “variants”
'variants'- MIN_PRICE =
product field “min_price”
'min_price'- MAX_PRICE =
product field “max_price”
'max_price'- IS_SALE =
product field “sale”
'sale'- DEFAULT_IMAGE =
product field “default_image”
'default_image'- ATTRIBUTES_MERGED =
product field “attributes_merged”
'attributes_merged'- CATEGORIES =
product field “categories”
'categories'- INACTIVE_VARIANTS =
product field “inactive_variants”
'inactive_variants'- MAX_SAVINGS =
product field “max_savings”
'max_savings'- MAX_SAVINGS_PERCENTAGE =
product field “max_savings_percentage”
'max_savings_percentage'- TAGS =
product field “tags”
'tags'
Class Method Summary collapse
-
.filter_fields(fields) ⇒ Object
filters a given set of fields.
-
.requires_categories(fields) ⇒ Object
determines whether the api call has to require Categories or not.
-
.requires_facets(fields) ⇒ Object
determines whether the api call has to require Facets or not.
Class Method Details
.filter_fields(fields) ⇒ Object
filters a given set of fields
-
Args :
-
fields-> an Array of product fields which should be filtered
-
-
Returns :
-
a filtered Array of product fields
-
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/AboutYou/Criteria/product_fields.rb', line 54 def self.filter_fields(fields) fields = fields.uniq # this simplifies parsing on (pre)fetching facets fields.push(ATTRIBUTES_MERGED) if fields.include?(ATTRIBUTES_MERGED) && (fields.include?(BRAND) || fields.include?(VARIANTS) || fields.include?(DEFAULT_VARIANT)) fields end |
.requires_categories(fields) ⇒ Object
determines whether the api call has to require Categories or not
-
Args :
-
fields-> an Array of product fields which should be filtered
-
-
Returns :
-
a boolean which is true when ap call has to require categories
-
93 94 95 |
# File 'lib/AboutYou/Criteria/product_fields.rb', line 93 def self.requires_categories(fields) fields.include?(CATEGORIES) end |
.requires_facets(fields) ⇒ Object
determines whether the api call has to require Facets or not
-
Args :
-
fields-> an Array of product fields which should be filtered
-
-
Returns :
-
a boolean which is true when ap call has to require facets
-
76 77 78 79 80 81 82 |
# File 'lib/AboutYou/Criteria/product_fields.rb', line 76 def self.requires_facets(fields) ([BRAND, VARIANTS, DEFAULT_VARIANT, ATTRIBUTES_MERGED ] & fields).count > 0 end |