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
@@ -0,0 +1,24 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
###
|
5
|
+
#
|
6
|
+
# This class is used as a model for a categories result
|
7
|
+
#
|
8
|
+
###
|
9
|
+
class CategoriesResult
|
10
|
+
attr_accessor :categories
|
11
|
+
attr_accessor :categories_not_found
|
12
|
+
attr_accessor :ids
|
13
|
+
|
14
|
+
def initialize(category_manager, ids)
|
15
|
+
self.ids = ids
|
16
|
+
self.categories = category_manager.categories(
|
17
|
+
ids,
|
18
|
+
AboutYou::SDK::Model::Category::ALL
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
###
|
5
|
+
#
|
6
|
+
# This class represents a category model
|
7
|
+
#
|
8
|
+
###
|
9
|
+
class Category
|
10
|
+
ALL = false
|
11
|
+
ACTIVE_ONLY = true
|
12
|
+
|
13
|
+
# @var integer */
|
14
|
+
attr_accessor :id
|
15
|
+
# @var string */
|
16
|
+
attr_accessor :name
|
17
|
+
# @var boolean */
|
18
|
+
attr_accessor :is_active
|
19
|
+
# @var integer */
|
20
|
+
attr_accessor :position
|
21
|
+
# @var Category */
|
22
|
+
attr_accessor :parent_id
|
23
|
+
# @var Category[] */
|
24
|
+
attr_accessor :all_subcategories
|
25
|
+
# @var Category[] */
|
26
|
+
attr_accessor :active_subcategories
|
27
|
+
# @var integer */
|
28
|
+
attr_accessor :product_count
|
29
|
+
attr_accessor :category_manager
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
self.all_subcategories = []
|
33
|
+
self.active_subcategories = []
|
34
|
+
end
|
35
|
+
|
36
|
+
###
|
37
|
+
# @param object $json_object json as object tree
|
38
|
+
# @param ModelFactoryInterface $factory
|
39
|
+
# @param Category|null $parent
|
40
|
+
#
|
41
|
+
# @return static
|
42
|
+
###
|
43
|
+
def self.create_from_json(json_object, cat_manager)
|
44
|
+
category = new
|
45
|
+
|
46
|
+
category.parent_id = json_object['parent']
|
47
|
+
category.id = json_object['id']
|
48
|
+
category.name = json_object['name']
|
49
|
+
category.is_active = json_object['active']
|
50
|
+
category.position = json_object['position']
|
51
|
+
category.category_manager = cat_manager
|
52
|
+
|
53
|
+
category
|
54
|
+
end
|
55
|
+
|
56
|
+
###
|
57
|
+
# @return boolean
|
58
|
+
###
|
59
|
+
def path_active?
|
60
|
+
is_active && (parent.nil? || parent.path_active?)
|
61
|
+
end
|
62
|
+
|
63
|
+
###
|
64
|
+
# @return Category|null
|
65
|
+
###
|
66
|
+
def parent
|
67
|
+
return nil unless parent_id
|
68
|
+
|
69
|
+
category_manager.category(parent_id)
|
70
|
+
end
|
71
|
+
|
72
|
+
###
|
73
|
+
# @param bool $activeOnly
|
74
|
+
#
|
75
|
+
# @return Category[]
|
76
|
+
###
|
77
|
+
def subcategories(active_only = ACTIVE_ONLY)
|
78
|
+
subcategories = category_manager.subcategories(id, active_only)
|
79
|
+
return subcategories if active_only == ALL
|
80
|
+
|
81
|
+
result = {}
|
82
|
+
|
83
|
+
subcategories.each do |key, subcat|
|
84
|
+
result[key] = subcat if subcat.is_active
|
85
|
+
end
|
86
|
+
|
87
|
+
result
|
88
|
+
end
|
89
|
+
|
90
|
+
###
|
91
|
+
# @return Category[]
|
92
|
+
###
|
93
|
+
def breadcrumb
|
94
|
+
breadcrumb = parent ? parent.breadcrumb : []
|
95
|
+
breadcrumb.push(self)
|
96
|
+
|
97
|
+
breadcrumb
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
###
|
5
|
+
#
|
6
|
+
# This class represents a category tree model
|
7
|
+
#
|
8
|
+
###
|
9
|
+
class CategoryTree
|
10
|
+
# @var CategoryManagerInterface */
|
11
|
+
attr_accessor :category_manager
|
12
|
+
|
13
|
+
def initialize(cat_manager)
|
14
|
+
self.category_manager = cat_manager
|
15
|
+
end
|
16
|
+
|
17
|
+
###
|
18
|
+
# @param bool $activeOnly if true, then only active categories will returned, otherwise all categories
|
19
|
+
#
|
20
|
+
# @return array|Category[]
|
21
|
+
###
|
22
|
+
def categories(act_only = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
23
|
+
category_manager.category_tree(act_only)
|
24
|
+
end
|
25
|
+
|
26
|
+
###
|
27
|
+
# Count active root all categories
|
28
|
+
#
|
29
|
+
# {@inheritdoc}
|
30
|
+
###
|
31
|
+
def count
|
32
|
+
categories(true).count
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
###
|
5
|
+
#
|
6
|
+
# This class represents a Facet model
|
7
|
+
#
|
8
|
+
###
|
9
|
+
class Facet
|
10
|
+
attr_accessor :json_object
|
11
|
+
# @var integer */
|
12
|
+
attr_accessor :id
|
13
|
+
# @var string */
|
14
|
+
attr_accessor :name
|
15
|
+
# @var string */
|
16
|
+
attr_accessor :value
|
17
|
+
# @var integer */
|
18
|
+
attr_accessor :group_id
|
19
|
+
# @var string */
|
20
|
+
attr_accessor :group_name
|
21
|
+
# @var array */
|
22
|
+
attr_accessor :options
|
23
|
+
|
24
|
+
###
|
25
|
+
# @param integer $id
|
26
|
+
# @param string $name
|
27
|
+
# @param string $value
|
28
|
+
# @param integer $group_id
|
29
|
+
# @param string $group_name
|
30
|
+
# @param array $options
|
31
|
+
###
|
32
|
+
def initialize(id, name, value, group_id, group_name, options = nil)
|
33
|
+
self.id = id
|
34
|
+
self.name = name
|
35
|
+
self.value = value
|
36
|
+
self.group_id = group_id
|
37
|
+
self.group_name = group_name
|
38
|
+
self.options = options
|
39
|
+
end
|
40
|
+
|
41
|
+
###
|
42
|
+
# @param $json_object
|
43
|
+
#
|
44
|
+
# @return static
|
45
|
+
###
|
46
|
+
def self.create_from_json(json_object)
|
47
|
+
new(
|
48
|
+
json_object['facet_id'],
|
49
|
+
json_object['name'],
|
50
|
+
json_object['value'] ? json_object['value'] : nil,
|
51
|
+
json_object['id'],
|
52
|
+
json_object['group_name'],
|
53
|
+
json_object['options'] ? json_object['options'] : nil
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
###
|
58
|
+
# a facet is unique with the combination about id and group id
|
59
|
+
#
|
60
|
+
# @return string
|
61
|
+
###
|
62
|
+
def unique_key(group_id = nil, facet_id = nil)
|
63
|
+
return String(group_id) + ':' + String(facet_id) unless
|
64
|
+
group_id.nil? && facet_id.nil?
|
65
|
+
|
66
|
+
String(self.group_id) + ':' + String(id) unless
|
67
|
+
self.group_id.nil? && self.facet_id.nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
###
|
71
|
+
# Get option value.
|
72
|
+
#
|
73
|
+
# @param string $key The option key.
|
74
|
+
#
|
75
|
+
# @return mixed
|
76
|
+
###
|
77
|
+
def option(key)
|
78
|
+
return unless options
|
79
|
+
options.each do |option|
|
80
|
+
return option['value'] if option['key'] == key
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
###
|
5
|
+
#
|
6
|
+
# This class represents a facet group model
|
7
|
+
#
|
8
|
+
###
|
9
|
+
class FacetGroup
|
10
|
+
# @var Facet[] */
|
11
|
+
attr_accessor :facets
|
12
|
+
# @var integer */
|
13
|
+
attr_accessor :id
|
14
|
+
# @var string */
|
15
|
+
attr_accessor :name
|
16
|
+
attr_accessor :group_id
|
17
|
+
|
18
|
+
###
|
19
|
+
# @param integer $id
|
20
|
+
# @param string $name
|
21
|
+
###
|
22
|
+
def initialize(id, name)
|
23
|
+
self.id = id
|
24
|
+
self.name = name
|
25
|
+
self.facets = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
###
|
29
|
+
# @param Facet $facet
|
30
|
+
###
|
31
|
+
def add_facet(facet)
|
32
|
+
facets[facet.id] = facet
|
33
|
+
end
|
34
|
+
|
35
|
+
###
|
36
|
+
# @param Facet[] $facet
|
37
|
+
###
|
38
|
+
def add_facets(facets)
|
39
|
+
facets.each do |facet|
|
40
|
+
add_facet(facet)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
###
|
45
|
+
# Returns all facet names separated with the given parameter
|
46
|
+
# eg. for size with to size facets "36" and "37" -> "36/37"
|
47
|
+
#
|
48
|
+
# @param string $separator
|
49
|
+
#
|
50
|
+
# @return string
|
51
|
+
###
|
52
|
+
def facet_names(separator = '/')
|
53
|
+
names = []
|
54
|
+
facets.each do |facet|
|
55
|
+
names.push(facet.name)
|
56
|
+
end
|
57
|
+
|
58
|
+
names.join(separator)
|
59
|
+
end
|
60
|
+
|
61
|
+
###
|
62
|
+
# facet groups are equal, if the ids and all child ids are equal
|
63
|
+
#
|
64
|
+
# @param FacetGroup $facet_group
|
65
|
+
#
|
66
|
+
# @return boolean
|
67
|
+
###
|
68
|
+
def equal?(facet_group)
|
69
|
+
return false unless id == facet_group.id
|
70
|
+
|
71
|
+
unique_key == facet_group.unique_key
|
72
|
+
end
|
73
|
+
|
74
|
+
###
|
75
|
+
# @see equal?
|
76
|
+
#
|
77
|
+
# @return string
|
78
|
+
###
|
79
|
+
def unique_key
|
80
|
+
facet_ids = facets.keys
|
81
|
+
facet_ids.sort!
|
82
|
+
|
83
|
+
String(id) + ':' + String(facet_ids.join(','))
|
84
|
+
end
|
85
|
+
|
86
|
+
def ids
|
87
|
+
{ id => facets.keys }
|
88
|
+
end
|
89
|
+
|
90
|
+
def contains(facet)
|
91
|
+
facets.key?(facet.id)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
###
|
5
|
+
#
|
6
|
+
# This class represents a facet group set model
|
7
|
+
#
|
8
|
+
###
|
9
|
+
class FacetGroupSet
|
10
|
+
# @var array */
|
11
|
+
attr_accessor :ids
|
12
|
+
# @var FacetGroup[] */
|
13
|
+
attr_accessor :groups
|
14
|
+
# @var Facet[] */
|
15
|
+
attr_accessor :facets
|
16
|
+
# @var FacetManagerInterface */
|
17
|
+
class << self
|
18
|
+
attr_accessor :facet_manager
|
19
|
+
end
|
20
|
+
|
21
|
+
###
|
22
|
+
# @param array $ids two dimensional array of group ids and array ids
|
23
|
+
#
|
24
|
+
# @throws \InvalidArgumentException
|
25
|
+
###
|
26
|
+
def initialize(ids)
|
27
|
+
self.facets = {}
|
28
|
+
self.groups = {}
|
29
|
+
ids.each do |_key, facet_ids|
|
30
|
+
fail '\InvalidArgumentException! ids must be an associative array
|
31
|
+
of [$groupId => [$facetId,...],..]' unless facet_ids.is_a?(Array)
|
32
|
+
end
|
33
|
+
|
34
|
+
self.ids = ids
|
35
|
+
end
|
36
|
+
|
37
|
+
###
|
38
|
+
# @return boolean
|
39
|
+
###
|
40
|
+
def empty?
|
41
|
+
ids.empty?
|
42
|
+
end
|
43
|
+
|
44
|
+
def gen_lazy_groups
|
45
|
+
groups = {}
|
46
|
+
ids.each do |group_id, facet_ids|
|
47
|
+
group = AboutYou::SDK::Model::FacetGroup.new(group_id, nil)
|
48
|
+
facet_ids.each do |facet_id|
|
49
|
+
facet = AboutYou::SDK::Model::Facet.new(
|
50
|
+
facet_id,
|
51
|
+
nil,
|
52
|
+
nil,
|
53
|
+
group_id,
|
54
|
+
nil
|
55
|
+
)
|
56
|
+
group.add_facet(facet)
|
57
|
+
end
|
58
|
+
groups[group_id] = group
|
59
|
+
end
|
60
|
+
|
61
|
+
groups
|
62
|
+
end
|
63
|
+
|
64
|
+
def lazy_groups
|
65
|
+
return @groups unless @groups.empty?
|
66
|
+
gen_lazy_groups
|
67
|
+
end
|
68
|
+
|
69
|
+
def fetch
|
70
|
+
return unless facets && facets.empty?
|
71
|
+
|
72
|
+
ids.each do |group_id, facet_ids|
|
73
|
+
facet = self.class.facet_manager.facet(group_id, facet_ids[0])
|
74
|
+
next unless facet
|
75
|
+
if @groups[group_id]
|
76
|
+
group = @groups[group_id]
|
77
|
+
else
|
78
|
+
group = AboutYou::SDK::Model::FacetGroup.new(
|
79
|
+
group_id,
|
80
|
+
facet.group_name
|
81
|
+
)
|
82
|
+
@groups[group_id] = group
|
83
|
+
end
|
84
|
+
group.add_facet(facet)
|
85
|
+
facets[facet.unique_key] = facet
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
###
|
90
|
+
# @return FacetGroup[]
|
91
|
+
###
|
92
|
+
def groups
|
93
|
+
fetch if @groups.empty?
|
94
|
+
|
95
|
+
@groups
|
96
|
+
end
|
97
|
+
|
98
|
+
###
|
99
|
+
# @param $group_id
|
100
|
+
#
|
101
|
+
# @return FacetGroup|null
|
102
|
+
###
|
103
|
+
def group(group_id)
|
104
|
+
return groups[group_id] if groups[group_id]
|
105
|
+
end
|
106
|
+
|
107
|
+
###
|
108
|
+
# @param $group_id
|
109
|
+
#
|
110
|
+
# @return bool
|
111
|
+
###
|
112
|
+
def group?(group_id)
|
113
|
+
!ids[group_id].empty?
|
114
|
+
end
|
115
|
+
|
116
|
+
###
|
117
|
+
# @param string $key
|
118
|
+
#
|
119
|
+
# @return Facet|null
|
120
|
+
###
|
121
|
+
def facet_by_key(key)
|
122
|
+
fetch
|
123
|
+
facets[key] ? facets[key] : nil
|
124
|
+
end
|
125
|
+
|
126
|
+
def facet(facet_group_id, facet_id)
|
127
|
+
fetch if facets.empty?
|
128
|
+
|
129
|
+
return facets[String(facet_group_id) + ':' + String(facet_id)] if
|
130
|
+
facets[String(facet_group_id) + ':' + String(facet_id)]
|
131
|
+
end
|
132
|
+
|
133
|
+
###
|
134
|
+
# set are equal, if all groups are equal
|
135
|
+
# which means, that all included facet ids per group must be the same
|
136
|
+
#
|
137
|
+
# @return string
|
138
|
+
###
|
139
|
+
def unique_key
|
140
|
+
ids.sort!
|
141
|
+
ids.map { |sub_ids| sub_ids.sort! }
|
142
|
+
|
143
|
+
ids.to_json
|
144
|
+
end
|
145
|
+
|
146
|
+
###
|
147
|
+
# @param FacetUniqueKeyInterface $facetCompable
|
148
|
+
#
|
149
|
+
# @return boolean
|
150
|
+
###
|
151
|
+
def contains(facet_compable)
|
152
|
+
return contains_facet_group_set(facet_compable) if
|
153
|
+
facet_compable.is_a?(self.class)
|
154
|
+
|
155
|
+
return contains_facet_get_group_interface(facet_compable) if
|
156
|
+
facet_compable.is_a? AboutYou::SDK::Model::FacetGetGroupInterface
|
157
|
+
|
158
|
+
false
|
159
|
+
end
|
160
|
+
|
161
|
+
def contains_facet_get_group_interface(facet)
|
162
|
+
lazy_groups = self.lazy_groups
|
163
|
+
id = facet.group_id
|
164
|
+
|
165
|
+
if lazy_groups.key?(id)
|
166
|
+
return lazy_groups[id].unique_key == facet.unique_key
|
167
|
+
end
|
168
|
+
|
169
|
+
false
|
170
|
+
end
|
171
|
+
|
172
|
+
def contains_facet_group_set(facet_group_set)
|
173
|
+
return true if unique_key == facet_group_set.unique_key
|
174
|
+
|
175
|
+
lazy_groups.each do |id, group|
|
176
|
+
return false if
|
177
|
+
lazy_groups['id'] || lazy_groups[id].unique_key != group.unique_key
|
178
|
+
end
|
179
|
+
|
180
|
+
true
|
181
|
+
end
|
182
|
+
|
183
|
+
def self.merge_facet_ids(facet_ids_array)
|
184
|
+
ids = {}
|
185
|
+
|
186
|
+
facet_ids_array.each do |facet_ids_hash|
|
187
|
+
facet_ids_hash.each do |group_id, facet_ids|
|
188
|
+
if ids[Integer(group_id)]
|
189
|
+
ids[Integer(group_id)] = ids[Integer(group_id)] +
|
190
|
+
facet_ids.uniq
|
191
|
+
else
|
192
|
+
ids[Integer(group_id)] = facet_ids
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
ids
|
198
|
+
end
|
199
|
+
|
200
|
+
###
|
201
|
+
# @return array
|
202
|
+
###
|
203
|
+
def group_ids
|
204
|
+
ids.keys
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|