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,15 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class CategoriesResult
|
5
|
-
attr_accessor :categories
|
6
|
-
attr_accessor :categoriesNotFound
|
7
|
-
|
8
|
-
def initialize(categoryManager, ids)
|
9
|
-
@ids = ids
|
10
|
-
@categories = categoryManager.categories(ids, AboutYou::SDK::Model::Category::ALL)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class Category
|
5
|
-
ALL = false;
|
6
|
-
ACTIVE_ONLY = true;
|
7
|
-
|
8
|
-
# @var integer */
|
9
|
-
attr_accessor :id
|
10
|
-
|
11
|
-
# @var string */
|
12
|
-
@name;
|
13
|
-
attr_accessor :name
|
14
|
-
|
15
|
-
# @var boolean */
|
16
|
-
@isActive;
|
17
|
-
attr_accessor :isActive
|
18
|
-
|
19
|
-
# @var integer */
|
20
|
-
@position;
|
21
|
-
attr_accessor :position
|
22
|
-
|
23
|
-
# @var Category */
|
24
|
-
@parentId;
|
25
|
-
attr_accessor :parentId
|
26
|
-
|
27
|
-
# @var Category[] */
|
28
|
-
@allsubcategories;
|
29
|
-
attr_accessor :allsubcategories
|
30
|
-
|
31
|
-
# @var Category[] */
|
32
|
-
@activesubcategories;
|
33
|
-
attr_accessor :activesubcategories
|
34
|
-
|
35
|
-
# @var integer */
|
36
|
-
@productCount;
|
37
|
-
attr_accessor :productCount
|
38
|
-
|
39
|
-
@categoryManager
|
40
|
-
attr_accessor :categoryManager
|
41
|
-
|
42
|
-
def initialize()
|
43
|
-
|
44
|
-
self.allsubcategories = Array(nil);
|
45
|
-
self.activesubcategories = Array(nil);
|
46
|
-
end
|
47
|
-
|
48
|
-
###
|
49
|
-
# @param object $jsonObject json as object tree
|
50
|
-
# @param ModelFactoryInterface $factory
|
51
|
-
# @param Category|null $parent
|
52
|
-
#
|
53
|
-
# @return static
|
54
|
-
###
|
55
|
-
def self.createFromJson(jsonObject, catManager)
|
56
|
-
category = self.new
|
57
|
-
|
58
|
-
category.parentId = jsonObject["parent"];
|
59
|
-
category.id = jsonObject["id"];
|
60
|
-
category.name = jsonObject["name"];
|
61
|
-
category.isActive = jsonObject["active"];
|
62
|
-
category.position = jsonObject["position"];
|
63
|
-
category.categoryManager = catManager
|
64
|
-
|
65
|
-
return category;
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
###
|
70
|
-
# @return boolean
|
71
|
-
###
|
72
|
-
def isPathActive()
|
73
|
-
|
74
|
-
parent = self.parent();
|
75
|
-
|
76
|
-
return self.isActive && (parent == nil || parent.isPathActive());
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
###
|
81
|
-
# @return Category|null
|
82
|
-
###
|
83
|
-
def parent
|
84
|
-
|
85
|
-
if (!self.parentId)
|
86
|
-
return nil;
|
87
|
-
end
|
88
|
-
|
89
|
-
return self.categoryManager.category(self.parentId);
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
###
|
94
|
-
# @param bool $activeOnly
|
95
|
-
#
|
96
|
-
# @return Category[]
|
97
|
-
###
|
98
|
-
def subcategories(activeOnly = ACTIVE_ONLY)
|
99
|
-
subcategories = self.categoryManager.subcategories(self.id, activeOnly);
|
100
|
-
if (activeOnly == ALL)
|
101
|
-
return subcategories;
|
102
|
-
end
|
103
|
-
result = Hash.new
|
104
|
-
|
105
|
-
subcategories.each do |key,subcat|
|
106
|
-
if subcat.isActive
|
107
|
-
result[key] = subcat
|
108
|
-
end
|
109
|
-
end;
|
110
|
-
|
111
|
-
return result
|
112
|
-
end
|
113
|
-
|
114
|
-
###
|
115
|
-
# @return Category[]
|
116
|
-
###
|
117
|
-
def breadcrumb()
|
118
|
-
breadcrumb = self.parent() ? self.parent().breadcrumb() : Array(nil);
|
119
|
-
breadcrumb.push(self)
|
120
|
-
|
121
|
-
return breadcrumb;
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class CategoryTree
|
5
|
-
# @var CategoryManagerInterface */
|
6
|
-
attr_accessor :categoryManager;
|
7
|
-
|
8
|
-
def initialize(categoryManager)
|
9
|
-
|
10
|
-
self.categoryManager = categoryManager;
|
11
|
-
end
|
12
|
-
|
13
|
-
###
|
14
|
-
# @param bool $activeOnly if true, then only active categories will returned, otherwise all categories
|
15
|
-
#
|
16
|
-
# @return array|Category[]
|
17
|
-
###
|
18
|
-
def categories(activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
19
|
-
|
20
|
-
return self.categoryManager.categoryTree(activeOnly);
|
21
|
-
end
|
22
|
-
|
23
|
-
###
|
24
|
-
# Count active root all categories
|
25
|
-
#
|
26
|
-
# {@inheritdoc}
|
27
|
-
###
|
28
|
-
def count()
|
29
|
-
|
30
|
-
return self.categories(true).count;
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class Facet
|
5
|
-
|
6
|
-
@jsonObject
|
7
|
-
attr_accessor :jsonObject
|
8
|
-
|
9
|
-
# @var integer */
|
10
|
-
@id;
|
11
|
-
attr_accessor :id
|
12
|
-
|
13
|
-
# @var string */
|
14
|
-
@name;
|
15
|
-
attr_accessor :name
|
16
|
-
|
17
|
-
# @var string */
|
18
|
-
@value;
|
19
|
-
attr_accessor :value
|
20
|
-
|
21
|
-
# @var integer */
|
22
|
-
@groupId;
|
23
|
-
attr_accessor :groupId
|
24
|
-
|
25
|
-
# @var string */
|
26
|
-
@groupName;
|
27
|
-
attr_accessor :groupName
|
28
|
-
|
29
|
-
# @var array */
|
30
|
-
@options;
|
31
|
-
attr_accessor :options
|
32
|
-
|
33
|
-
###
|
34
|
-
# @param integer $id
|
35
|
-
# @param string $name
|
36
|
-
# @param string $value
|
37
|
-
# @param integer $groupId
|
38
|
-
# @param string $groupName
|
39
|
-
# @param array $options
|
40
|
-
###
|
41
|
-
def initialize(id, name, value, groupId, groupName, options = nil)
|
42
|
-
|
43
|
-
self.id = id;
|
44
|
-
self.name = name;
|
45
|
-
self.value = value;
|
46
|
-
self.groupId = groupId;
|
47
|
-
self.groupName = groupName;
|
48
|
-
self.options = options;
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
###
|
53
|
-
# @param $jsonObject
|
54
|
-
#
|
55
|
-
# @return static
|
56
|
-
###
|
57
|
-
def self.createFromJson(jsonObject)
|
58
|
-
|
59
|
-
return self.new(
|
60
|
-
jsonObject["facet_id"],
|
61
|
-
jsonObject["name"],
|
62
|
-
(jsonObject["value"]) ? jsonObject["value"] : nil,
|
63
|
-
jsonObject["id"],
|
64
|
-
jsonObject["group_name"],
|
65
|
-
jsonObject["options"] ? jsonObject["options"] : nil
|
66
|
-
)
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
###
|
71
|
-
# a facet is unique with the combination about id and group id
|
72
|
-
#
|
73
|
-
# @return string
|
74
|
-
###
|
75
|
-
def uniqueKey(groupId = nil, facetId = nil)
|
76
|
-
|
77
|
-
return String(self.groupId) + ':' + String(self.id) if(groupId == nil && facetId == nil)
|
78
|
-
return String(groupId) + ':' + String(facetId) if(groupId != nil && facetId != nil)
|
79
|
-
return nil
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
###
|
84
|
-
# Get option value.
|
85
|
-
#
|
86
|
-
# @param string $key The option key.
|
87
|
-
#
|
88
|
-
# @return mixed
|
89
|
-
###
|
90
|
-
def option(key)
|
91
|
-
|
92
|
-
if (self.options)
|
93
|
-
self.options.each do |option|
|
94
|
-
if (option["key"] == key)
|
95
|
-
return option["value"];
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
return nil;
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class FacetGroup
|
5
|
-
|
6
|
-
# @var Facet[] */
|
7
|
-
@facets;
|
8
|
-
attr_accessor :facets
|
9
|
-
|
10
|
-
# @var integer */
|
11
|
-
@id;
|
12
|
-
attr_accessor :id
|
13
|
-
|
14
|
-
# @var string */
|
15
|
-
@name;
|
16
|
-
attr_accessor :name
|
17
|
-
|
18
|
-
@groupId
|
19
|
-
attr_accessor :groupId
|
20
|
-
|
21
|
-
###
|
22
|
-
# @param integer $id
|
23
|
-
# @param string $name
|
24
|
-
###
|
25
|
-
def initialize(id, name)
|
26
|
-
|
27
|
-
self.id = id;
|
28
|
-
self.name = name;
|
29
|
-
self.facets = Hash.new
|
30
|
-
end
|
31
|
-
|
32
|
-
###
|
33
|
-
# @param Facet $facet
|
34
|
-
###
|
35
|
-
def addFacet(facet)
|
36
|
-
|
37
|
-
self.facets[facet.id] = facet;
|
38
|
-
end
|
39
|
-
|
40
|
-
###
|
41
|
-
# @param Facet[] $facet
|
42
|
-
###
|
43
|
-
def addFacets(facets)
|
44
|
-
|
45
|
-
facets.each do |facet|
|
46
|
-
self.addFacet(facet);
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
###
|
52
|
-
# Returns all facet names separated with the given parameter
|
53
|
-
# eg. for size with to size facets "36" and "37" -> "36/37"
|
54
|
-
#
|
55
|
-
# @param string $separator
|
56
|
-
#
|
57
|
-
# @return string
|
58
|
-
###
|
59
|
-
def facetNames(separator = '/')
|
60
|
-
|
61
|
-
names = Array(nil);
|
62
|
-
self.facets.each do |facet|
|
63
|
-
names.push(facetname());
|
64
|
-
end
|
65
|
-
|
66
|
-
return name.join(seperator)
|
67
|
-
end
|
68
|
-
|
69
|
-
###
|
70
|
-
# facet groups are equal, if the ids and all child ids are equal
|
71
|
-
#
|
72
|
-
# @param FacetGroup $facetGroup
|
73
|
-
#
|
74
|
-
# @return boolean
|
75
|
-
###
|
76
|
-
def isEqual(facetGroup)
|
77
|
-
|
78
|
-
return false if (self.id != facetGroup.id)
|
79
|
-
|
80
|
-
return self.uniqueKey() == facetGroup.uniqueKey();
|
81
|
-
end
|
82
|
-
|
83
|
-
###
|
84
|
-
# @see isEqual
|
85
|
-
#
|
86
|
-
# @return string
|
87
|
-
###
|
88
|
-
def uniqueKey()
|
89
|
-
|
90
|
-
facetIds = self.facets.keys
|
91
|
-
facetIds.sort
|
92
|
-
|
93
|
-
return String(self.id) + ':' + String(facetIds.join(','))
|
94
|
-
end
|
95
|
-
|
96
|
-
def ids()
|
97
|
-
|
98
|
-
return Hash[self.id => self.facets.keys]
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
def contains(facet)
|
104
|
-
|
105
|
-
return self.facets[facet.id].defined?
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
@@ -1,242 +0,0 @@
|
|
1
|
-
module AboutYou
|
2
|
-
module SDK
|
3
|
-
module Model
|
4
|
-
class FacetGroupSet
|
5
|
-
|
6
|
-
# @var array */
|
7
|
-
attr_accessor :ids;
|
8
|
-
|
9
|
-
# @var FacetGroup[] */
|
10
|
-
attr_accessor :groups;
|
11
|
-
|
12
|
-
# @var Facet[] */
|
13
|
-
attr_accessor :facets;
|
14
|
-
|
15
|
-
# @var FacetManagerInterface */
|
16
|
-
class << self
|
17
|
-
attr_accessor :facetManager
|
18
|
-
end
|
19
|
-
|
20
|
-
###
|
21
|
-
# @param array $ids two dimensional array of group ids and array ids
|
22
|
-
#
|
23
|
-
# @throws \InvalidArgumentException
|
24
|
-
###
|
25
|
-
def initialize(ids)
|
26
|
-
self.facets = Hash.new
|
27
|
-
self.groups = Hash.new
|
28
|
-
ids.each do |key, facetIds|
|
29
|
-
unless facetIds.is_a? Array
|
30
|
-
raise '\InvalidArgumentException! ids must be an associative array of array: [$groupId => [$facetId,...],...]'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
self.ids = ids;
|
35
|
-
end
|
36
|
-
|
37
|
-
###
|
38
|
-
# @return boolean
|
39
|
-
###
|
40
|
-
def isEmpty()
|
41
|
-
|
42
|
-
return self.ids.empty?
|
43
|
-
end
|
44
|
-
|
45
|
-
def genLazyGroups()
|
46
|
-
|
47
|
-
groups = Hash.new
|
48
|
-
self.ids.each do |groupId, facetIds|
|
49
|
-
group = AboutYou::SDK::Model::FacetGroup.new(groupId, nil);
|
50
|
-
facetIds.each do |facetId|
|
51
|
-
facet = AboutYou::SDK::Model::Facet.new(facetId, nil, nil, groupId, nil);
|
52
|
-
group.addFacet(facet);
|
53
|
-
end
|
54
|
-
groups[groupId] = group;
|
55
|
-
end
|
56
|
-
|
57
|
-
return groups;
|
58
|
-
end
|
59
|
-
|
60
|
-
def lazyGroups()
|
61
|
-
|
62
|
-
if !(self.facets.empty?)
|
63
|
-
return self.groups;
|
64
|
-
else
|
65
|
-
return self.genLazyGroups();
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def fetch
|
70
|
-
unless self.facets && self.facets.empty?
|
71
|
-
return
|
72
|
-
end
|
73
|
-
|
74
|
-
self.ids.each do |groupId, facetIds|
|
75
|
-
facet = self.class.facetManager.facet(groupId, facetIds[0])
|
76
|
-
|
77
|
-
unless facet
|
78
|
-
# TODO: error handling
|
79
|
-
next
|
80
|
-
end
|
81
|
-
|
82
|
-
if @groups[groupId]
|
83
|
-
group = @groups[groupId]
|
84
|
-
else
|
85
|
-
group = AboutYou::SDK::Model::FacetGroup.new(groupId, facet.groupName)
|
86
|
-
@groups[groupId] = group
|
87
|
-
end
|
88
|
-
group.addFacet(facet);
|
89
|
-
self.facets[facet.uniqueKey] = facet;
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
###
|
94
|
-
# @return FacetGroup[]
|
95
|
-
###
|
96
|
-
def groups
|
97
|
-
if @groups.empty?
|
98
|
-
self.fetch
|
99
|
-
end
|
100
|
-
|
101
|
-
@groups
|
102
|
-
end
|
103
|
-
|
104
|
-
###
|
105
|
-
# @param $groupId
|
106
|
-
#
|
107
|
-
# @return FacetGroup|null
|
108
|
-
###
|
109
|
-
def group(groupId)
|
110
|
-
|
111
|
-
groups = self.groups
|
112
|
-
if (groups[groupId])
|
113
|
-
return groups[groupId];
|
114
|
-
end
|
115
|
-
|
116
|
-
return nil;
|
117
|
-
end
|
118
|
-
|
119
|
-
###
|
120
|
-
# @param $groupId
|
121
|
-
#
|
122
|
-
# @return bool
|
123
|
-
###
|
124
|
-
def hasGroup(groupId)
|
125
|
-
|
126
|
-
return !(self.ids[groupId].empty?);
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
###
|
131
|
-
# @param string $key
|
132
|
-
#
|
133
|
-
# @return Facet|null
|
134
|
-
###
|
135
|
-
def facetByKey(key)
|
136
|
-
|
137
|
-
self.fetch();
|
138
|
-
|
139
|
-
self.facets[key] ? self.facets[key] : nil
|
140
|
-
end
|
141
|
-
|
142
|
-
|
143
|
-
def facet(facetGroupId, facetId)
|
144
|
-
|
145
|
-
if (self.facets.empty?)
|
146
|
-
self.fetch();
|
147
|
-
end
|
148
|
-
|
149
|
-
if (self.facets[String(facetGroupId)+':'+String(facetId)])
|
150
|
-
return(self.facets[String(facetGroupId)+':'+String(facetId)]);
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# ###
|
155
|
-
# # set are equal, if all groups are equal
|
156
|
-
# # which means, that all included facet ids per group must be the same
|
157
|
-
# #
|
158
|
-
# # @return string
|
159
|
-
# ###
|
160
|
-
# def uniqueKey()
|
161
|
-
#
|
162
|
-
# ids = self.ids;
|
163
|
-
# asort($ids);
|
164
|
-
# array_walk($ids, 'sort');
|
165
|
-
#
|
166
|
-
# return json_encode($ids);
|
167
|
-
# end
|
168
|
-
|
169
|
-
###
|
170
|
-
# @param FacetUniqueKeyInterface $facetCompable
|
171
|
-
#
|
172
|
-
# @return boolean
|
173
|
-
###
|
174
|
-
def contains(facetCompable)
|
175
|
-
|
176
|
-
if (facetCompable.is_a? self.class)
|
177
|
-
return self.containsFacetGroupSet(facetCompable);
|
178
|
-
end
|
179
|
-
|
180
|
-
# if (facetCompable.is_a? AboutYou::SDK::Model::FacetGetGroupInterface)
|
181
|
-
# return $this->containsFacetGetGroupInterface($facetCompable);
|
182
|
-
# }
|
183
|
-
|
184
|
-
return false;
|
185
|
-
end
|
186
|
-
|
187
|
-
# private function containsFacetGetGroupInterface(FacetGetGroupInterface $facet)
|
188
|
-
# {
|
189
|
-
# $myLazyGroups = $this->getLazyGroups();
|
190
|
-
# $id = $facet->getGroupId();
|
191
|
-
#
|
192
|
-
# if (isset($myLazyGroups[$id])) {
|
193
|
-
# return $myLazyGroups[$id]->getUniqueKey() === $facet->getUniqueKey();
|
194
|
-
# }
|
195
|
-
#
|
196
|
-
# return false;
|
197
|
-
# }
|
198
|
-
|
199
|
-
def containsFacetGroupSet(facetGroupSet)
|
200
|
-
|
201
|
-
if (self.uniqueKey() == facetGroupSet.uniqueKey())
|
202
|
-
return true;
|
203
|
-
end
|
204
|
-
|
205
|
-
myLazyGroups = self.lazyGroups();
|
206
|
-
self.facetGroupSet.lazyGroups.each do |id, group|
|
207
|
-
if ((myLazyGroups["id"]) || myLazyGroups[id].uniqueKey() != group.uniqueKey())
|
208
|
-
return false;
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
return true;
|
213
|
-
end
|
214
|
-
|
215
|
-
def self.mergeFacetIds(facetIdsArray)
|
216
|
-
|
217
|
-
ids = {}
|
218
|
-
facetIdsArray.each do |facetIdsHash|
|
219
|
-
facetIdsHash.each do |groupId, facetIds|
|
220
|
-
if (ids[Integer(groupId)])
|
221
|
-
ids[Integer(groupId)] = (ids[Integer(groupId)] + facetIds).uniq
|
222
|
-
else
|
223
|
-
ids[Integer(groupId)] = facetIds;
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
return ids;
|
229
|
-
end
|
230
|
-
|
231
|
-
###
|
232
|
-
# @return array
|
233
|
-
###
|
234
|
-
def groupIds()
|
235
|
-
|
236
|
-
return self.ids.keys
|
237
|
-
end
|
238
|
-
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|