aboutyou-sdk 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/aboutyou-sdk/Criteria/ProductSearchCriteria.rb +2 -3
- data/lib/aboutyou-sdk/Model/CategoryManager/DefaultCategoryManager.rb +196 -153
- data/lib/aboutyou-sdk/Model/FacetGroupSet.rb +17 -19
- data/lib/aboutyou-sdk/Model/FacetManager/DefaultFacetManager.rb +0 -1
- data/lib/aboutyou-sdk/Model/Variant.rb +7 -6
- data/lib/aboutyou-sdk/Query.rb +0 -2
- data/lib/aboutyou-sdk.rb +12 -6
- data/tests/Sinatra-test/Main.rb +1 -1
- data/tests/testCatTree.rb +0 -1
- data/tests/testDalli.rb +15 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWI2YjA3YmNlNTE2ZTE4YzQ4YWM0NGZkMTYyYTQ5ZjM4MjZiNDQxOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODZhYjdhYWZlOWFkOGY3MzdhMDg0NjhjMmM1ZWJiODM4NzZkNDIyNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODBmNGUxMGUzMzk3MmJjODk5NjhmZDllZDJjYTc1YmMzNGZlMjZhYWE1ZDBk
|
10
|
+
NjdkMmVmZmRjNmJhODJjODNhMDhmZmIwMDRmMDJlZGJlODE1MDU2ODA5ODdj
|
11
|
+
ZTgwMTA5MTVjNDdmNzc1YWViYmNhNjlhOWZkMWY2Y2NlY2VlZDI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWY3NzA5ZTgwZTRjZDQ1NzdiYTdlOTUwMmRiYjVmNjgzZGJhYWQ0ZWFlZDUw
|
14
|
+
YWQ1NzhkNDYxZTVlYmYwZDFmMmZiNWNjMmM1YTgzZGFhYzY1NzMzNGUyZDE1
|
15
|
+
MzM1NDRjYWI2MTgwYzljYjczMWJjNjYyM2JkYmE5NjY5NzY5OGY=
|
@@ -75,7 +75,7 @@ module AboutYou
|
|
75
75
|
# - an instance of AboutYou::SDK::Criteria::ProductSearchCriteria
|
76
76
|
###
|
77
77
|
def filterBy(key, value)
|
78
|
-
filter[key] = value
|
78
|
+
@filter[key] = value
|
79
79
|
return self
|
80
80
|
end
|
81
81
|
|
@@ -164,7 +164,6 @@ module AboutYou
|
|
164
164
|
end
|
165
165
|
attributes = merged
|
166
166
|
end
|
167
|
-
|
168
167
|
self.filterBy(FILTER_ATTRIBUTES, attributes)
|
169
168
|
end
|
170
169
|
|
@@ -458,7 +457,7 @@ module AboutYou
|
|
458
457
|
params['result'] = self.result
|
459
458
|
end
|
460
459
|
unless @filter.empty?
|
461
|
-
params['filter'] =
|
460
|
+
params['filter'] = @filter
|
462
461
|
end
|
463
462
|
|
464
463
|
params
|
@@ -2,169 +2,212 @@ module AboutYou
|
|
2
2
|
module SDK
|
3
3
|
module Model
|
4
4
|
module CategoryManager
|
5
|
+
###
|
6
|
+
# This class is responsible for handling all the logic when working with
|
7
|
+
# categories
|
8
|
+
#
|
9
|
+
# author:: Collins GmbH & Co KG
|
10
|
+
###
|
5
11
|
class DefaultCategoryManager
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
12
|
+
# the duration for the cached values to live
|
13
|
+
DEFAULT_CACHE_DURATION = 7200
|
14
|
+
|
15
|
+
# the read-in categories from the category manager
|
16
|
+
attr_accessor :categories
|
17
|
+
# the parent child ids for the categories
|
18
|
+
attr_accessor :parentChildIds
|
19
|
+
# the cache client
|
20
|
+
attr_accessor :cache
|
21
|
+
# the cache key for the app
|
22
|
+
attr_accessor :cacheKey
|
23
|
+
|
24
|
+
###
|
25
|
+
# the Constructor for the AY class
|
26
|
+
#
|
27
|
+
# * *Args* :
|
28
|
+
# - +cache+ -> The cache client set on the AY class
|
29
|
+
# - +appId+ -> The App-Id of the App
|
30
|
+
#
|
31
|
+
# * *Returns* :
|
32
|
+
# - Instance of AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager
|
33
|
+
###
|
34
|
+
def initialize(cache = nil, appId = '')
|
35
|
+
self.cache = cache
|
36
|
+
self.cacheKey = 'AY:SDK:' + String(appId) + ':categories'
|
37
|
+
self.loadCachedCategories
|
38
|
+
end
|
39
|
+
|
40
|
+
###
|
41
|
+
# Gets the cached Categories for this app
|
42
|
+
###
|
43
|
+
def loadCachedCategories
|
44
|
+
if self.cache
|
45
|
+
self.categories = self.cache.get(self.cacheKey) ? self.cache.get(self.cacheKey) : nil
|
34
46
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
if (self.cache)
|
46
|
-
self.cache.save(self.cacheKey, self.categories,DEFAULT_CACHE_DURATION);
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def clearCache()
|
51
|
-
|
52
|
-
if (self.cache)
|
53
|
-
self.cache.delete(self.cacheKey);
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
###
|
58
|
-
# @param \stdObject $jsonObject
|
59
|
-
# @param ModelFactoryInterface $factory
|
60
|
-
#
|
61
|
-
# @return $this
|
62
|
-
###
|
63
|
-
def parseJson(jsonObject, factory)
|
64
|
-
self.categories = Hash.new
|
65
|
-
self.parentChildIds = jsonObject["parent_child"]
|
66
|
-
|
67
|
-
jsonObject["ids"].each do |id, jsonCategory|
|
68
|
-
@categories[id] = factory.createCategory(jsonCategory);
|
69
|
-
end
|
70
|
-
self.cacheCategories();
|
71
|
-
|
72
|
-
return self
|
73
|
-
end
|
74
|
-
|
75
|
-
###
|
76
|
-
# {@inheritdoc}
|
77
|
-
###
|
78
|
-
def isEmpty()
|
79
|
-
|
80
|
-
return (@categories == nil);
|
81
|
-
end
|
82
|
-
|
83
|
-
###
|
84
|
-
# {@inheritdoc}
|
85
|
-
###
|
86
|
-
def categoryTree(activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
87
|
-
|
88
|
-
return self.subcategories(0, activeOnly);
|
47
|
+
end
|
48
|
+
|
49
|
+
###
|
50
|
+
# This method caches the currently read-in categories
|
51
|
+
###
|
52
|
+
def cacheCategories
|
53
|
+
if self.cache
|
54
|
+
binding.pry
|
55
|
+
self.cache.set(self.cacheKey, self.categories, DEFAULT_CACHE_DURATION)
|
89
56
|
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
return self.categories[String(id)];
|
57
|
+
end
|
58
|
+
|
59
|
+
###
|
60
|
+
# This method clears the cache
|
61
|
+
###
|
62
|
+
def clearCache
|
63
|
+
if self.cache
|
64
|
+
self.cache.delete(self.cacheKey)
|
100
65
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
end
|
121
|
-
return categories;
|
66
|
+
end
|
67
|
+
|
68
|
+
###
|
69
|
+
# this method parses a json object received from the api and
|
70
|
+
# creates models from it
|
71
|
+
#
|
72
|
+
# * *Args* :
|
73
|
+
# - +jsonObject+ -> the jsonObject received from the api
|
74
|
+
# - +factory+ -> the model factory used for creating the models
|
75
|
+
#
|
76
|
+
# * *Returns* :
|
77
|
+
# - Instance of AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager
|
78
|
+
###
|
79
|
+
def parseJson(jsonObject, factory)
|
80
|
+
self.categories = {}
|
81
|
+
self.parentChildIds = jsonObject["parent_child"]
|
82
|
+
|
83
|
+
jsonObject["ids"].each do |id, jsonCategory|
|
84
|
+
self.categories[id] = factory.createCategory(jsonCategory)
|
122
85
|
end
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
86
|
+
self.cacheCategories()
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
###
|
91
|
+
# this method checks whether this category manager has read-in
|
92
|
+
# categories or not
|
93
|
+
#
|
94
|
+
# * *Returns* :
|
95
|
+
# - a boolean which determines whether this catManager has read-in categories or not
|
96
|
+
###
|
97
|
+
def isEmpty
|
98
|
+
self.categories == nil
|
99
|
+
end
|
100
|
+
|
101
|
+
###
|
102
|
+
# This method returns the root categories for the read-in categories
|
103
|
+
#
|
104
|
+
# * *Args* :
|
105
|
+
# - +activeOnly+ -> determines whether the result should contain only active categories or not
|
106
|
+
#
|
107
|
+
# * *Returns* :
|
108
|
+
# - a Hash containing pairs of Category_Id => instance of AboutYou::SDK::Model::Category
|
109
|
+
###
|
110
|
+
def categoryTree(activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
111
|
+
self.subcategories(0, activeOnly)
|
112
|
+
end
|
113
|
+
|
114
|
+
###
|
115
|
+
# This method is used for getting a category model by a given id
|
116
|
+
#
|
117
|
+
# * *Args* :
|
118
|
+
# - +id+ -> the id for which a category model should be returned
|
119
|
+
#
|
120
|
+
# * *Returns* :
|
121
|
+
# - either an instance of AboutYou::SDK::Model::Category or nil if +id+ is not found
|
122
|
+
###
|
123
|
+
def category(id)
|
124
|
+
return nil unless @categories[String(id)]
|
125
|
+
@categories[String(id)]
|
126
|
+
end
|
127
|
+
|
128
|
+
###
|
129
|
+
# This method is used for getting either all categories when +id+
|
130
|
+
# is nil or a Hash of all Category Models found for an Array of
|
131
|
+
# Category Ids
|
132
|
+
#
|
133
|
+
# * *Args* :
|
134
|
+
# - +ids+ -> an Array of category Ids
|
135
|
+
# - +activeOnly+ -> determines whether the result should contain only active categories or not
|
136
|
+
#
|
137
|
+
# * *Returns* :
|
138
|
+
# - a Hash containing pairs of Category_ID => an Instance of AboutYou::SDK::Model::Category
|
139
|
+
###
|
140
|
+
def categories(ids=nil, activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
141
|
+
return @categories if ids == nil
|
142
|
+
return {} unless @categories
|
143
|
+
|
144
|
+
categories = {}
|
145
|
+
|
146
|
+
ids.each do |id|
|
147
|
+
if category(id)
|
148
|
+
category = category(id)
|
149
|
+
if activeOnly == AboutYou::SDK::Model::Category::ALL || category.isActive
|
150
|
+
categories[id] = category
|
135
151
|
end
|
136
|
-
|
137
|
-
ids = self.parentChildIds[String(id)];
|
138
|
-
return self.categories(ids, activeOnly);
|
152
|
+
end
|
139
153
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
154
|
+
categories
|
155
|
+
end
|
156
|
+
|
157
|
+
###
|
158
|
+
# This method gets the subcategories for a given category id
|
159
|
+
#
|
160
|
+
# * *Args* :
|
161
|
+
# - +id+ -> an Array of category Ids
|
162
|
+
# - +activeOnly+ -> determines whether the result should contain only active categories or not
|
163
|
+
#
|
164
|
+
# * *Returns* :
|
165
|
+
# - a Hash containing pairs of Category_ID => an Instance of AboutYou::SDK::Model::Category
|
166
|
+
###
|
167
|
+
def subcategories(id, activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
168
|
+
return Array(nil) unless self.parentChildIds.key?(String(id))
|
169
|
+
self.categories(self.parentChildIds[String(id)], activeOnly)
|
170
|
+
end
|
171
|
+
|
172
|
+
###
|
173
|
+
# This method gets the first category which has a certain name
|
174
|
+
#
|
175
|
+
# * *Args* :
|
176
|
+
# - +name+ -> the name which should be found
|
177
|
+
# - +activeOnly+ -> determines whether the result should contain only active categories or not
|
178
|
+
#
|
179
|
+
# * *Returns* :
|
180
|
+
# - either an instance of AboutYou::SDK::Model::Category or nil if +name+ not found
|
181
|
+
###
|
182
|
+
def firstCategoryByName(name, activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
183
|
+
self.categories.each do |category|
|
184
|
+
if category.name == name && (activeOnly == AboutYou::SDK::Model::Category::ACTIVE_ONLY || category.isActive)
|
185
|
+
return category
|
186
|
+
end
|
153
187
|
end
|
154
188
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
189
|
+
nil
|
190
|
+
end
|
191
|
+
|
192
|
+
###
|
193
|
+
# This method gets the subcategories for a given category id
|
194
|
+
#
|
195
|
+
# * *Args* :
|
196
|
+
# - +id+ -> an Array of category Ids
|
197
|
+
# - +activeOnly+ -> determines whether the result should contain only active categories or not
|
198
|
+
#
|
199
|
+
# * *Returns* :
|
200
|
+
# - a Hash containing pairs of Category_ID => an Instance of AboutYou::SDK::Model::Category
|
201
|
+
###
|
202
|
+
def categoriesByName(name, activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
|
203
|
+
resultCategories = []
|
204
|
+
self.categories.each do |category|
|
205
|
+
if category.name == name && (activeOnly == AboutYou::SDK::Model::Category::ALL || category.isActive)
|
206
|
+
resultCategories.push(category)
|
207
|
+
end
|
167
208
|
end
|
209
|
+
resultCategories
|
210
|
+
end
|
168
211
|
end
|
169
212
|
end
|
170
213
|
end
|
@@ -66,28 +66,27 @@ module AboutYou
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def fetch
|
69
|
+
def fetch
|
70
70
|
|
71
|
-
|
72
|
-
return
|
71
|
+
unless self.facets
|
72
|
+
return
|
73
73
|
end
|
74
74
|
self.ids.each do |idPair|
|
75
75
|
|
76
76
|
idPair.each do |groupId, facetIds|
|
77
|
-
facet = self.class.facetManager.facet(groupId, facetIds)
|
77
|
+
facet = self.class.facetManager.facet(groupId, facetIds[0])
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
unless facet
|
80
|
+
# TODO: error handling
|
81
81
|
next
|
82
82
|
end
|
83
83
|
|
84
|
-
if
|
85
|
-
group =
|
84
|
+
if @groups[groupId]
|
85
|
+
group = @groups[groupId]
|
86
86
|
else
|
87
|
-
group = AboutYou::SDK::Model::FacetGroup.new(groupId, facet.groupName
|
88
|
-
|
87
|
+
group = AboutYou::SDK::Model::FacetGroup.new(groupId, facet.groupName)
|
88
|
+
@groups[groupId] = group
|
89
89
|
end
|
90
|
-
|
91
90
|
group.addFacet(facet);
|
92
91
|
self.facets[facet.uniqueKey] = facet;
|
93
92
|
end
|
@@ -97,13 +96,12 @@ module AboutYou
|
|
97
96
|
###
|
98
97
|
# @return FacetGroup[]
|
99
98
|
###
|
100
|
-
def groups
|
101
|
-
|
102
|
-
|
103
|
-
self.fetch();
|
99
|
+
def groups
|
100
|
+
if @groups.empty?
|
101
|
+
self.fetch
|
104
102
|
end
|
105
|
-
|
106
|
-
|
103
|
+
|
104
|
+
@groups
|
107
105
|
end
|
108
106
|
|
109
107
|
###
|
@@ -113,8 +111,8 @@ module AboutYou
|
|
113
111
|
###
|
114
112
|
def group(groupId)
|
115
113
|
|
116
|
-
groups = self.groups
|
117
|
-
if (groups[
|
114
|
+
groups = self.groups
|
115
|
+
if (groups[groupId])
|
118
116
|
return groups[groupId];
|
119
117
|
end
|
120
118
|
|
@@ -27,6 +27,7 @@ module AboutYou
|
|
27
27
|
attr_accessor :color
|
28
28
|
attr_accessor :length
|
29
29
|
attr_accessor :seasonCode
|
30
|
+
attr_accessor :jsonObject
|
30
31
|
|
31
32
|
###
|
32
33
|
# @param \stdClass $jsonObject
|
@@ -43,8 +44,9 @@ module AboutYou
|
|
43
44
|
end
|
44
45
|
|
45
46
|
variant = self.new
|
46
|
-
variant.factory = factory
|
47
|
-
variant.product = product
|
47
|
+
variant.factory = factory
|
48
|
+
variant.product = product
|
49
|
+
variant.jsonObject = jsonObject
|
48
50
|
|
49
51
|
|
50
52
|
variant.parseImages(jsonObj["images"])
|
@@ -141,7 +143,7 @@ module AboutYou
|
|
141
143
|
if !(jsonObject["attributes"].empty?)
|
142
144
|
jsonObject["attributes"].each do |group, aIds|
|
143
145
|
gid = group[11..group.length] # rm prefix "attributs_"
|
144
|
-
ids.push(Hash[gid => aIds]);
|
146
|
+
ids.push(Hash[Integer(gid) => aIds]);
|
145
147
|
end
|
146
148
|
end
|
147
149
|
|
@@ -172,9 +174,8 @@ module AboutYou
|
|
172
174
|
#
|
173
175
|
# @return FacetGroup|null
|
174
176
|
###
|
175
|
-
|
176
|
-
|
177
|
-
return self.facetGroupSet(jsonObject).group(groupId);
|
177
|
+
def facetGroup(groupId, jsonObject=self.jsonObject)
|
178
|
+
return self.facetGroupSet(jsonObject).group(groupId)
|
178
179
|
end
|
179
180
|
|
180
181
|
###
|
data/lib/aboutyou-sdk/Query.rb
CHANGED
@@ -323,7 +323,6 @@ module AboutYou
|
|
323
323
|
jsonObject = responseObject[resultKey]
|
324
324
|
queryKey = currentQuery.keys[0]
|
325
325
|
factory = self.factory
|
326
|
-
|
327
326
|
if (jsonObject.is_a? Hash) && jsonObject['error_code']
|
328
327
|
result = factory.preHandleError(jsonObject, resultKey, isMultiRequest)
|
329
328
|
if result != false
|
@@ -331,7 +330,6 @@ module AboutYou
|
|
331
330
|
next
|
332
331
|
end
|
333
332
|
end
|
334
|
-
|
335
333
|
query = currentQuery[queryKey]
|
336
334
|
queryId = queryIds[index]
|
337
335
|
if queryId == QUERY_FACETS
|
data/lib/aboutyou-sdk.rb
CHANGED
@@ -37,6 +37,8 @@ class AY
|
|
37
37
|
attr_accessor :baseImageUrl
|
38
38
|
# the session id from a user using this app
|
39
39
|
attr_accessor :sessionId
|
40
|
+
# the CacheServer
|
41
|
+
attr_accessor :cache
|
40
42
|
|
41
43
|
###
|
42
44
|
# the Constructor for the AY class
|
@@ -48,7 +50,7 @@ class AY
|
|
48
50
|
# - +apiEndPoint+ -> Can be either live or staging
|
49
51
|
# - +resultFactory+ -> If nil it will use the DefaultModelFactory with the DefaultFacetManager
|
50
52
|
# - +logger+ -> Logger-Template
|
51
|
-
# - +
|
53
|
+
# - +cache+ -> The prefered Caching-Strategy
|
52
54
|
#
|
53
55
|
# * *Returns* :
|
54
56
|
# - Instance of AY
|
@@ -57,12 +59,11 @@ class AY
|
|
57
59
|
appId,
|
58
60
|
appPassword,
|
59
61
|
sessionId = 'SESSION_ID',
|
62
|
+
cache = nil,
|
60
63
|
apiEndPoint = AboutYou::SDK::Constants::API_ENVIRONMENT_LIVE,
|
61
64
|
resultFactory = nil,
|
62
|
-
logger = nil
|
63
|
-
facetManagerCache = nil
|
65
|
+
logger = nil
|
64
66
|
)
|
65
|
-
|
66
67
|
self.sessionId = sessionId
|
67
68
|
self.appId = appId
|
68
69
|
self.appPassword = appPassword
|
@@ -72,7 +73,6 @@ class AY
|
|
72
73
|
apiEndPoint,
|
73
74
|
logger
|
74
75
|
)
|
75
|
-
resultFactory ? self.modelFactoryInstance = resultFactory : initDefaultFactory(facetManagerCache)
|
76
76
|
|
77
77
|
if apiEndPoint == AboutYou::SDK::Constants::API_ENVIRONMENT_STAGE
|
78
78
|
self.baseImageUrl = (IMAGE_URL_STAGE)
|
@@ -83,6 +83,11 @@ class AY
|
|
83
83
|
else
|
84
84
|
self.baseImageUrl = (IMAGE_URL_LIVE)
|
85
85
|
end
|
86
|
+
if cache == 'memcache'
|
87
|
+
require 'dalli'
|
88
|
+
self.cache = Dalli::Client.new('localhost:11211')
|
89
|
+
end
|
90
|
+
resultFactory ? self.modelFactoryInstance = resultFactory : initDefaultFactory(self.cache)
|
86
91
|
end
|
87
92
|
|
88
93
|
###
|
@@ -371,6 +376,8 @@ class AY
|
|
371
376
|
def fetchFacets(groupIds=[])
|
372
377
|
|
373
378
|
query.fetchFacets(groupIds).executeSingle
|
379
|
+
|
380
|
+
self.modelFactoryInstance.facetManager.facets
|
374
381
|
end
|
375
382
|
|
376
383
|
|
@@ -574,7 +581,6 @@ class AY
|
|
574
581
|
# - +cache+ -> an Instance of the used cache [optional]
|
575
582
|
###
|
576
583
|
def initDefaultFactory(cache = nil)
|
577
|
-
|
578
584
|
resultFactory = AboutYou::SDK::Factory::DefaultModelFactory.new(self,
|
579
585
|
AboutYou::SDK::Model::FacetManager::DefaultFacetManager.new,
|
580
586
|
AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager.new(cache, self.appId)
|
data/tests/Sinatra-test/Main.rb
CHANGED
data/tests/testCatTree.rb
CHANGED
data/tests/testDalli.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require "pry_debug"
|
3
|
+
require_relative'../lib/aboutyou-sdk.rb'
|
4
|
+
|
5
|
+
shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', 'memcache')
|
6
|
+
|
7
|
+
shop.fetchProductsByIds(
|
8
|
+
[661132, 660971, 661367, 661361],
|
9
|
+
[AboutYou::SDK::Criteria::ProductFields::CATEGORIES,
|
10
|
+
AboutYou::SDK::Criteria::ProductFields::VARIANTS]
|
11
|
+
)
|
12
|
+
get "/" do
|
13
|
+
binding.pry
|
14
|
+
return shop.cache.get('AY:SDK:281:categories')
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aboutyou-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferenc Beutel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- tests/testAutocomplete.rb
|
105
105
|
- tests/testCatFilter.rb
|
106
106
|
- tests/testCatTree.rb
|
107
|
+
- tests/testDalli.rb
|
107
108
|
- tests/testFacetTypes.rb
|
108
109
|
- tests/testFacets.rb
|
109
110
|
- tests/testFetchFacet.rb
|