aboutyou-sdk 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/{aboutyou-sdk/CacheProvider/Dalli.rb → AboutYou/CacheProvider/dalli.rb} +18 -19
- data/lib/{aboutyou-sdk/CacheProvider/Redis.rb → AboutYou/CacheProvider/redis.rb} +19 -20
- data/lib/{aboutyou-sdk/Criteria/ProductFields.rb → AboutYou/Criteria/product_fields.rb} +25 -27
- data/lib/{aboutyou-sdk/Criteria/ProductSearchCriteria.rb → AboutYou/Criteria/product_search_criteria.rb} +128 -123
- data/lib/{aboutyou-sdk/Factory/DefaultModelFactory.rb → AboutYou/Factory/default_model_factory.rb} +267 -224
- data/lib/AboutYou/Model/Basket/abstract_basket_item.rb +57 -0
- data/lib/AboutYou/Model/Basket/basket_item.rb +95 -0
- data/lib/AboutYou/Model/Basket/basket_set.rb +199 -0
- data/lib/AboutYou/Model/Basket/basket_set_item.rb +54 -0
- data/lib/AboutYou/Model/Basket/basket_variant_item.rb +123 -0
- data/lib/{aboutyou-sdk/Model/CategoryManager/DefaultCategoryManager.rb → AboutYou/Model/CategoryManager/default_category_manager.rb} +80 -65
- data/lib/{aboutyou-sdk/Model/FacetManager/DefaultFacetManager.rb → AboutYou/Model/FacetManager/default_facet_manager.rb} +58 -50
- data/lib/{aboutyou-sdk/Model/ProductSearchResult/FacetCount.rb → AboutYou/Model/ProductSearchResult/facet_count.rb} +2 -3
- data/lib/AboutYou/Model/ProductSearchResult/facet_counts.rb +67 -0
- data/lib/{aboutyou-sdk/Model/ProductSearchResult/PriceRange.rb → AboutYou/Model/ProductSearchResult/price_range.rb} +17 -18
- data/lib/AboutYou/Model/ProductSearchResult/sale_counts.rb +79 -0
- data/lib/AboutYou/Model/ProductSearchResult/terms_count.rb +40 -0
- data/lib/{aboutyou-sdk/Model/AbstractModel.rb → AboutYou/Model/abstract_model.rb} +2 -3
- data/lib/{aboutyou-sdk/Model/App.rb → AboutYou/Model/app.rb} +15 -15
- data/lib/{aboutyou-sdk/Model/Autocomplete.rb → AboutYou/Model/autocomplete.rb} +25 -32
- data/lib/AboutYou/Model/basket.rb +235 -0
- data/lib/AboutYou/Model/categories_result.rb +24 -0
- data/lib/AboutYou/Model/category.rb +102 -0
- data/lib/AboutYou/Model/category_tree.rb +37 -0
- data/lib/AboutYou/Model/facet.rb +86 -0
- data/lib/AboutYou/Model/facet_group.rb +96 -0
- data/lib/AboutYou/Model/facet_group_set.rb +209 -0
- data/lib/AboutYou/Model/image.rb +102 -0
- data/lib/{aboutyou-sdk/Model/ImageSize.rb → AboutYou/Model/image_size.rb} +9 -5
- data/lib/AboutYou/Model/initiate_order.rb +53 -0
- data/lib/AboutYou/Model/order.rb +22 -0
- data/lib/AboutYou/Model/product.rb +353 -0
- data/lib/AboutYou/Model/product_search_result.rb +114 -0
- data/lib/AboutYou/Model/products_ean_result.rb +43 -0
- data/lib/AboutYou/Model/products_result.rb +56 -0
- data/lib/AboutYou/Model/result_error.rb +28 -0
- data/lib/AboutYou/Model/variant.rb +214 -0
- data/lib/AboutYou/Model/variants_result.rb +91 -0
- data/lib/AboutYou/client.rb +128 -0
- data/lib/{aboutyou-sdk/Constants.rb → AboutYou/constants.rb} +3 -5
- data/lib/AboutYou/query.rb +343 -0
- data/lib/AboutYou/query_builder.rb +530 -0
- data/lib/ay.rb +566 -0
- data/tests/Sinatra-test/Main.rb +3 -0
- data/tests/testAutocomplete.rb +5 -6
- data/tests/testCatFilter.rb +8 -9
- data/tests/testCatTree.rb +3 -3
- data/tests/testCategoryCaching.rb +4 -5
- data/tests/{testFacetCaching.rb → testDalliCache.rb} +4 -5
- data/tests/testFacetTypes.rb +5 -6
- data/tests/testFacets.rb +7 -8
- data/tests/testFetchFacet.rb +5 -6
- data/tests/testJavaScript.rb +3 -4
- data/tests/testProdCatLongestPath.rb +7 -8
- data/tests/testProductSearchResult.rb +6 -7
- data/tests/testProductsByEans.rb +6 -7
- data/tests/testProductsByIds.rb +6 -7
- data/tests/testRedisCache.rb +4 -5
- data/tests/testSuggest.rb +5 -6
- data/tests/testVariantsByIds.rb +7 -8
- metadata +46 -46
- data/lib/aboutyou-sdk.rb +0 -596
- data/lib/aboutyou-sdk/Client.rb +0 -134
- data/lib/aboutyou-sdk/Model/Basket.rb +0 -268
- data/lib/aboutyou-sdk/Model/Basket/AbstractBasketItem.rb +0 -76
- data/lib/aboutyou-sdk/Model/Basket/BasketItem.rb +0 -100
- data/lib/aboutyou-sdk/Model/Basket/BasketSet.rb +0 -192
- data/lib/aboutyou-sdk/Model/Basket/BasketSetItem.rb +0 -46
- data/lib/aboutyou-sdk/Model/Basket/BasketVariantItem.rb +0 -137
- data/lib/aboutyou-sdk/Model/CategoriesResult.rb +0 -15
- data/lib/aboutyou-sdk/Model/Category.rb +0 -126
- data/lib/aboutyou-sdk/Model/CategoryTree.rb +0 -35
- data/lib/aboutyou-sdk/Model/Facet.rb +0 -105
- data/lib/aboutyou-sdk/Model/FacetGroup.rb +0 -110
- data/lib/aboutyou-sdk/Model/FacetGroupSet.rb +0 -242
- data/lib/aboutyou-sdk/Model/Image.rb +0 -134
- data/lib/aboutyou-sdk/Model/InitiateOrder.rb +0 -50
- data/lib/aboutyou-sdk/Model/Order.rb +0 -17
- data/lib/aboutyou-sdk/Model/Product.rb +0 -335
- data/lib/aboutyou-sdk/Model/ProductSearchResult.rb +0 -125
- data/lib/aboutyou-sdk/Model/ProductSearchResult/FacetCounts.rb +0 -59
- data/lib/aboutyou-sdk/Model/ProductSearchResult/SaleCounts.rb +0 -71
- data/lib/aboutyou-sdk/Model/ProductSearchResult/TermsCount.rb +0 -36
- data/lib/aboutyou-sdk/Model/ProductsEansResult.rb +0 -47
- data/lib/aboutyou-sdk/Model/ProductsResult.rb +0 -52
- data/lib/aboutyou-sdk/Model/ResultError.rb +0 -24
- data/lib/aboutyou-sdk/Model/Variant.rb +0 -255
- data/lib/aboutyou-sdk/Model/VariantsResult.rb +0 -102
- data/lib/aboutyou-sdk/Query.rb +0 -350
- data/lib/aboutyou-sdk/QueryBuilder.rb +0 -499
@@ -1,134 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class Image
|
5
|
-
MIN_WIDTH = 50;
|
6
|
-
MIN_HEIGHT = 50;
|
7
|
-
MAX_WIDTH = 1400;
|
8
|
-
MAX_HEIGHT = 2000;
|
9
|
-
|
10
|
-
@@baseUrl
|
11
|
-
class << self
|
12
|
-
attr_accessor :baseUrl
|
13
|
-
end
|
14
|
-
|
15
|
-
# @var null|string[] */
|
16
|
-
@additionalItems;
|
17
|
-
attr_accessor :additionalItems
|
18
|
-
|
19
|
-
# @var null|string */
|
20
|
-
@angle;
|
21
|
-
attr_accessor :angle
|
22
|
-
|
23
|
-
# @var null|string */
|
24
|
-
@background;
|
25
|
-
attr_accessor :background
|
26
|
-
|
27
|
-
# @var null|string[] */
|
28
|
-
@color;
|
29
|
-
attr_accessor :color
|
30
|
-
|
31
|
-
# @var null|string */
|
32
|
-
@ext;
|
33
|
-
attr_accessor :ext
|
34
|
-
|
35
|
-
# @var null|string */
|
36
|
-
@gender;
|
37
|
-
attr_accessor :gender
|
38
|
-
|
39
|
-
# @var string */
|
40
|
-
@hash;
|
41
|
-
attr_accessor :hash
|
42
|
-
|
43
|
-
# @var ImageSize */
|
44
|
-
@imageSize;
|
45
|
-
attr_accessor :imageSize
|
46
|
-
|
47
|
-
# @var integer */
|
48
|
-
@fileSize;
|
49
|
-
attr_accessor :fileSize
|
50
|
-
|
51
|
-
# @var null|string */
|
52
|
-
@focus;
|
53
|
-
attr_accessor :focus
|
54
|
-
|
55
|
-
# @var string */
|
56
|
-
@mimeType;
|
57
|
-
attr_accessor :mimeType
|
58
|
-
|
59
|
-
# @var null|\stdClass */
|
60
|
-
@modelData;
|
61
|
-
attr_accessor :modelData
|
62
|
-
|
63
|
-
# @var null|integer */
|
64
|
-
@nextDetailLevel;
|
65
|
-
attr_accessor :nextDetailLevel
|
66
|
-
|
67
|
-
# @var null|string */
|
68
|
-
@preparation;
|
69
|
-
attr_accessor :preparation
|
70
|
-
|
71
|
-
# @var null|array */
|
72
|
-
@tags;
|
73
|
-
attr_accessor :tags
|
74
|
-
|
75
|
-
# @var null|string */
|
76
|
-
@type;
|
77
|
-
attr_accessor :type
|
78
|
-
|
79
|
-
# @var string */
|
80
|
-
@view;
|
81
|
-
attr_accessor :view
|
82
|
-
|
83
|
-
|
84
|
-
###
|
85
|
-
# @param \stdClass $jsonObject
|
86
|
-
#
|
87
|
-
# @return static
|
88
|
-
###
|
89
|
-
def self.createFromJson(jsonObject)
|
90
|
-
|
91
|
-
image = self.new
|
92
|
-
|
93
|
-
image.additionalItems = (jsonObject["additional_items"]) ? jsonObject["additional_items"] : nil;
|
94
|
-
image.angle = (jsonObject["angle"]) ? jsonObject["angle"] : nil;
|
95
|
-
image.background = (jsonObject["background"]) ? jsonObject["background"] : nil;
|
96
|
-
image.color = (jsonObject["color"]) ? jsonObject["color"] : nil;
|
97
|
-
image.ext = (jsonObject["ext"]) ? jsonObject["ext"] : nil;
|
98
|
-
image.fileSize = (jsonObject["size"]) ? jsonObject["size"] : 0;
|
99
|
-
image.focus = (jsonObject["focus"]) ? jsonObject["focus"] : nil;
|
100
|
-
image.gender = (jsonObject["gender"]) ? jsonObject["gender"] : nil;
|
101
|
-
image.hash = (jsonObject["hash"]) ? jsonObject["hash"] : nil;
|
102
|
-
image.mimeType = (jsonObject["mime"]) ? jsonObject["mime"] : nil;
|
103
|
-
image.modelData = (jsonObject["model_data"]) ? jsonObject["model_data"] : nil;
|
104
|
-
image.nextDetailLevel = (jsonObject["next_detail_level"]) ? jsonObject["next_detail_level"] : nil;
|
105
|
-
image.preparation = (jsonObject["preparation"]) ? jsonObject["preparation"] : nil;
|
106
|
-
image.tags = (jsonObject["tags"]) ? jsonObject["tags"] : nil;
|
107
|
-
image.type = (jsonObject["type"]) ? jsonObject["type"] : nil;
|
108
|
-
image.view = (jsonObject["view"]) ? jsonObject["view"] : nil;
|
109
|
-
|
110
|
-
|
111
|
-
image.imageSize = ImageSize.new(Integer(jsonObject["image"]["width"]), Integer(jsonObject["image"]["height"]));
|
112
|
-
|
113
|
-
return image;
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
###
|
119
|
-
# @param int $width
|
120
|
-
# @param int $height
|
121
|
-
#
|
122
|
-
# @return string returns the relative url
|
123
|
-
###
|
124
|
-
def url(width = 200, height = 200)
|
125
|
-
|
126
|
-
width = [[width, MAX_WIDTH].min, MIN_WIDTH].max;
|
127
|
-
height = [[height, MAX_HEIGHT].min, MIN_HEIGHT].max;
|
128
|
-
|
129
|
-
self.class.baseUrl + '/' + self.hash + '?width=' + String(width) + '&height=' + String(height);
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class InitiateOrder
|
5
|
-
|
6
|
-
attr_accessor :url
|
7
|
-
attr_accessor :userToken
|
8
|
-
attr_accessor :appToken
|
9
|
-
attr_accessor :errorCode
|
10
|
-
attr_accessor :errorMessage
|
11
|
-
|
12
|
-
###
|
13
|
-
# @param string $url
|
14
|
-
# @param string $userToken
|
15
|
-
# @param string $appToken
|
16
|
-
###
|
17
|
-
def initialize(url, userToken, appToken)
|
18
|
-
|
19
|
-
self.url = url;
|
20
|
-
self.userToken = userToken;
|
21
|
-
self.appToken = appToken;
|
22
|
-
end
|
23
|
-
|
24
|
-
###
|
25
|
-
# @param \stdClass $json
|
26
|
-
#
|
27
|
-
# @return static
|
28
|
-
###
|
29
|
-
def self.createFromJson(jsonObject)
|
30
|
-
|
31
|
-
order = self.new(
|
32
|
-
jsonObject["url"],
|
33
|
-
jsonObject["user_token"],
|
34
|
-
jsonObject["app_token"]
|
35
|
-
);
|
36
|
-
|
37
|
-
order.parseErrorResult(jsonObject);
|
38
|
-
|
39
|
-
return order;
|
40
|
-
end
|
41
|
-
|
42
|
-
def parseErrorResult(jsonObject)
|
43
|
-
|
44
|
-
self.errorCode = (jsonObject.key?("error_code")) ? jsonObject["error_code"] : 0
|
45
|
-
self.errorCode = (jsonObject.key?("error_message")) ? jsonObject["error_message"] : nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,335 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class Product
|
5
|
-
include AbstractModel
|
6
|
-
|
7
|
-
attr_accessor :id
|
8
|
-
attr_accessor :factory
|
9
|
-
attr_accessor :name
|
10
|
-
attr_accessor :isSale
|
11
|
-
attr_accessor :isActive
|
12
|
-
attr_accessor :descriptionShort
|
13
|
-
attr_accessor :descriptionLong
|
14
|
-
attr_accessor :minPrice
|
15
|
-
attr_accessor :maxPrice
|
16
|
-
attr_accessor :maxSavingsPrice
|
17
|
-
attr_accessor :maxSavings
|
18
|
-
attr_accessor :maxSavingsPercentage
|
19
|
-
attr_accessor :brandId
|
20
|
-
attr_accessor :merchantId
|
21
|
-
attr_accessor :categoryIdPaths
|
22
|
-
attr_accessor :facetIds
|
23
|
-
attr_accessor :defaultImage
|
24
|
-
attr_accessor :defaultVariant
|
25
|
-
attr_accessor :selectedVariant
|
26
|
-
attr_accessor :variants
|
27
|
-
attr_accessor :inactiveVariants
|
28
|
-
attr_accessor :styles
|
29
|
-
attr_accessor :facetGroups
|
30
|
-
attr_accessor :rootCategories
|
31
|
-
attr_accessor :activeRootCategories
|
32
|
-
attr_accessor :leafCategories
|
33
|
-
attr_accessor :activeLeafCategories
|
34
|
-
|
35
|
-
|
36
|
-
def self.createFromJson(jsonObject, factory, appId)
|
37
|
-
product = self.new
|
38
|
-
# these are required fields
|
39
|
-
raise 'MalformedJsonException!' unless jsonObject["id"] || jsonObject["name"]
|
40
|
-
|
41
|
-
product.factory = factory
|
42
|
-
|
43
|
-
product.id = jsonObject["id"]
|
44
|
-
product.name = jsonObject["name"]
|
45
|
-
|
46
|
-
product.isSale = jsonObject["sale"] ? jsonObject["sale"] : false
|
47
|
-
product.descriptionShort = jsonObject["description_short"] ? jsonObject["description_short"] : ''
|
48
|
-
product.descriptionLong = jsonObject["description_long"] ? jsonObject["description_long"] : ''
|
49
|
-
product.isActive = jsonObject["active"] ? jsonObject["active"] : true
|
50
|
-
product.brandId = jsonObject["brand_id"] ? jsonObject["brand_id"] : nil
|
51
|
-
product.merchantId = jsonObject["merchant_id"] ? jsonObject["merchant_id"] : nil
|
52
|
-
|
53
|
-
product.minPrice = jsonObject["min_price"] ? jsonObject["min_price"] : nil
|
54
|
-
product.maxPrice = jsonObject["max_price"] ? jsonObject["max_price"] : nil
|
55
|
-
product.maxSavingsPrice = jsonObject["max_savings"] ? jsonObject["max_savings"] : nil
|
56
|
-
product.maxSavingsPercentage = jsonObject["max_savings_percentage"] ? jsonObject["max_savings_percentage"] : nil
|
57
|
-
|
58
|
-
product.defaultImage = jsonObject["default_image"] ? factory.createImage(jsonObject["default_image"]) : nil
|
59
|
-
product.defaultVariant = jsonObject["default_variant"] ? factory.createVariant(jsonObject["default_variant"], self) : nil
|
60
|
-
|
61
|
-
product.variants = product.parseVariants(jsonObject, factory, product)
|
62
|
-
product.inactiveVariants = product.parseVariants(jsonObject, factory, product, 'inactive_variants')
|
63
|
-
product.styles = product.parseStyles(jsonObject, factory)
|
64
|
-
|
65
|
-
key = 'categories.' + String(appId)
|
66
|
-
product.categoryIdPaths = jsonObject[key] ? jsonObject[key] : []
|
67
|
-
|
68
|
-
product.facetIds = product.parseFacetIds(jsonObject)
|
69
|
-
|
70
|
-
product
|
71
|
-
end
|
72
|
-
|
73
|
-
def parseVariants(jsonObject, factory, product, attributeName = 'variants')
|
74
|
-
variants = {}
|
75
|
-
if jsonObject.key?(attributeName) && !jsonObject[attributeName].empty?
|
76
|
-
jsonObject[attributeName].each do |jsonVariant|
|
77
|
-
variants[jsonVariant["id"]] = factory.createVariant(jsonVariant, product)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
variants
|
82
|
-
end
|
83
|
-
|
84
|
-
def parseStyles(jsonObject, factory)
|
85
|
-
styles = []
|
86
|
-
if jsonObject.key?("styles") && !jsonObject["styles"].empty?
|
87
|
-
jsonObject["styles"].each do |style|
|
88
|
-
styles.push(factory.createProduct(style))
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
styles
|
93
|
-
end
|
94
|
-
|
95
|
-
def parseCategoryIdPaths(jsonObject)
|
96
|
-
paths = []
|
97
|
-
|
98
|
-
jsonObject.each do |name, categoryPaths|
|
99
|
-
if name.index('categories') === 0
|
100
|
-
paths = categoryPaths
|
101
|
-
break
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
paths
|
106
|
-
end
|
107
|
-
|
108
|
-
def parseFacetIds(jsonObject)
|
109
|
-
ids = self.parseFacetIdsInAttributesMerged(jsonObject)
|
110
|
-
|
111
|
-
ids = self.parseFacetIdsInVariants(jsonObject) if ids === nil
|
112
|
-
|
113
|
-
ids = self.parseFacetIdsInBrand(jsonObject) if $ids === nil
|
114
|
-
|
115
|
-
ids != nil ? ids : []
|
116
|
-
end
|
117
|
-
|
118
|
-
def parseFacetIdsInAttributesMerged(jsonObject)
|
119
|
-
return nil unless jsonObject["attributes_merged"]
|
120
|
-
|
121
|
-
self.parseAttributesJson(jsonObject["attributes_merged"])
|
122
|
-
end
|
123
|
-
|
124
|
-
def parseAttributesJson(attributesJsonObject)
|
125
|
-
ids = {}
|
126
|
-
|
127
|
-
attributesJsonObject.each do |group, facetIds|
|
128
|
-
gid = group[11..group.length] # rm prefix "attributes"
|
129
|
-
|
130
|
-
# TODO: Remove Workaround for Ticket ???
|
131
|
-
facetIds = Array(facetIds)
|
132
|
-
ids[gid] = facetIds
|
133
|
-
end
|
134
|
-
|
135
|
-
ids
|
136
|
-
end
|
137
|
-
|
138
|
-
def parseFacetIdsInVariants(jsonObject)
|
139
|
-
if jsonObject["variants"]
|
140
|
-
ids = []
|
141
|
-
jsonObject["variants"].each do |variant|
|
142
|
-
ids.push(self.parseAttributesJson(variant["attributes"]))
|
143
|
-
end
|
144
|
-
ids = AboutYou::SDK::Model::FacetGroupSet.mergeFacetIds(ids)
|
145
|
-
return ids
|
146
|
-
elsif jsonObject["default_variant"]
|
147
|
-
ids = self.parseAttributesJson(jsonObject["default_variant"]["attributes"])
|
148
|
-
return ids
|
149
|
-
end
|
150
|
-
|
151
|
-
nil
|
152
|
-
end
|
153
|
-
|
154
|
-
def parseFacetIdsInBrand(jsonObject)
|
155
|
-
return nil unless jsonObject["brand_id"]
|
156
|
-
|
157
|
-
{'0' => [jsonObject["brand_id"]]}
|
158
|
-
end
|
159
|
-
|
160
|
-
def generateFacetGroupSet
|
161
|
-
raise 'RuntimeException! To use this method, you must add the field ProductFields::ATTRIBUTES_MERGED to the "product search" or "products by ids"' if self.facetIds.empty?
|
162
|
-
|
163
|
-
self.facetGroups = AboutYou::SDK::Model::FacetGroupSet.new(self.facetIds)
|
164
|
-
end
|
165
|
-
|
166
|
-
def facetGroupSet
|
167
|
-
self.generateFacetGroupSet unless @facetGroups
|
168
|
-
|
169
|
-
@facetGroups
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
def category(active = false)
|
174
|
-
return nil unless self.categoryIdPaths
|
175
|
-
|
176
|
-
self.leafCategories(active)[self.leafCategories(active).keys[0]]
|
177
|
-
end
|
178
|
-
|
179
|
-
def categoryWithLongestActivePath
|
180
|
-
|
181
|
-
return nil unless self.categoryIdPaths
|
182
|
-
|
183
|
-
self.categoryIdPaths.sort!{|x,y| y.count <=> x.count}.each do |path|
|
184
|
-
return self.factory.categoryManager.category(path[-1]) if self.factory.categoryManager.category(path[-1]).isPathActive
|
185
|
-
end
|
186
|
-
nil
|
187
|
-
end
|
188
|
-
|
189
|
-
def leafCategories(activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
190
|
-
self.factory.categoryManager.categories(self.leafCategoryIds, activeOnly)
|
191
|
-
end
|
192
|
-
|
193
|
-
|
194
|
-
def rootCategoryIds
|
195
|
-
rootCategories = []
|
196
|
-
self.categoryIdPaths.each do |categoryIdPath|
|
197
|
-
rootCategories.push(categoryIdPath[0])
|
198
|
-
end
|
199
|
-
|
200
|
-
rootCategories.uniq
|
201
|
-
end
|
202
|
-
|
203
|
-
def leafCategoryIds
|
204
|
-
leafCategories = []
|
205
|
-
self.categoryIdPaths.each do |categoryIdPath|
|
206
|
-
leafCategories.push(categoryIdPath[-1])
|
207
|
-
end
|
208
|
-
|
209
|
-
leafCategories.uniq
|
210
|
-
end
|
211
|
-
|
212
|
-
def categories(activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
213
|
-
self.rootCategories(activeOnly)
|
214
|
-
end
|
215
|
-
|
216
|
-
def rootCategories(activeOnly = Category::ACTIVE_ONLY)
|
217
|
-
self.factory.categoryManager.categories(self.rootCategoryIds, activeOnly)
|
218
|
-
end
|
219
|
-
|
220
|
-
def groupFacets(groupId)
|
221
|
-
return group.facets if self.facetGroupSet.group(groupId)
|
222
|
-
[]
|
223
|
-
end
|
224
|
-
|
225
|
-
def facetGroups(groupId)
|
226
|
-
allGroups = {}
|
227
|
-
self.variants.each do |variant|
|
228
|
-
variant.facetGroupSet.groups.each do |group|
|
229
|
-
allGroups[group.uniqueKey] = group if group.id === groupId
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
allGroups
|
234
|
-
end
|
235
|
-
|
236
|
-
def selectableFacetGroups(selectedFacetGroupSet)
|
237
|
-
allGroups = {}
|
238
|
-
|
239
|
-
self.variants.each do |variant|
|
240
|
-
facetGroupSet = variant.facetGroupSet
|
241
|
-
ids = facetGroupSet.groupIds
|
242
|
-
|
243
|
-
if facetGroupSet.contains(selectedFacetGroupSet)
|
244
|
-
ids.each do |groupId|
|
245
|
-
next if selectedFacetGroupSet.groupIds.include?(groupId)
|
246
|
-
group = facetGroupSet.group(groupId)
|
247
|
-
raise 'RuntimeException! group for id ' + String(groupId) + ' not found' if group === nil
|
248
|
-
|
249
|
-
allGroups[groupId] = {group.uniqueKey => group}
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
selectedFacetGroupSet.groupIds.each do |groupId|
|
255
|
-
selectedFacetGroupSet.ids[groupId] = nil
|
256
|
-
self.variants.each do |variant|
|
257
|
-
facetGroupSet = variant.facetGroupSet
|
258
|
-
allGroups[groupId] = {group.uniqueKey => facetGroupSet.group(groupId)} if facetGroupSet.contains(AboutYou::SDK::Model::FacetGroupSet.new(ids))
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
allGroups
|
263
|
-
end
|
264
|
-
|
265
|
-
|
266
|
-
def excludedFacetGroups(selectedFacetGroupSet)
|
267
|
-
allGroups = {}
|
268
|
-
selectedGroupIds = selectedFacetGroupSet.groupIds
|
269
|
-
|
270
|
-
self.variants.each do |variant|
|
271
|
-
facetGroupSet = variant.facetGroupSet
|
272
|
-
next unless facetGroupSet.contains(selectedFacetGroupSet)
|
273
|
-
|
274
|
-
facetGroupSet.groupIds.each do |groupId|
|
275
|
-
next if selectedFacetGroupSet.groupIds.include?(groupId)
|
276
|
-
|
277
|
-
group = facetGroupSet.group(groupId)
|
278
|
-
raise 'RuntimeException! group for id ' + String(groupId) + ' not found' if group == nil
|
279
|
-
|
280
|
-
facets = group.facets
|
281
|
-
next unless facets
|
282
|
-
|
283
|
-
unless allGroups[groupId]
|
284
|
-
allGroups[groupId] = AboutYou::SDK::Model::FacetGroup.new(group.id, group.name)
|
285
|
-
allGroups[groupId].addFacets(facets)
|
286
|
-
end
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
allGroups
|
291
|
-
end
|
292
|
-
|
293
|
-
|
294
|
-
def brand
|
295
|
-
self.facetGroupSet.facet(AboutYou::SDK::Constants::FACET_BRAND, self.brandId)
|
296
|
-
end
|
297
|
-
|
298
|
-
def variantById(variantId)
|
299
|
-
self.variants[variantId] ? self.variants[variantId] : nil
|
300
|
-
end
|
301
|
-
|
302
|
-
|
303
|
-
def variantsByEan(ean)
|
304
|
-
variants = []
|
305
|
-
self.variants.each do |key, variant|
|
306
|
-
variants.push(variant) if variant.ean == ean
|
307
|
-
end
|
308
|
-
|
309
|
-
variants
|
310
|
-
end
|
311
|
-
|
312
|
-
|
313
|
-
def variantByFacets(facetGroupSet)
|
314
|
-
key = facetGroupSet.uniqueKey
|
315
|
-
self.variants.each do |variant|
|
316
|
-
return variant if variant.facetGroupSet.uniqueKey == key
|
317
|
-
end
|
318
|
-
|
319
|
-
nil
|
320
|
-
end
|
321
|
-
|
322
|
-
|
323
|
-
def variantsByFacetId(facetId, groupId)
|
324
|
-
variants = []
|
325
|
-
facet = AboutYou::SDK::Facet.new(facetId, '', '', groupId, '')
|
326
|
-
self.variants.each do |variant|
|
327
|
-
variants.push(variant) if variant.facetGroupSez.contains(facet)
|
328
|
-
end
|
329
|
-
|
330
|
-
variants
|
331
|
-
end
|
332
|
-
end
|
333
|
-
end
|
334
|
-
end
|
335
|
-
end
|