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.
Files changed (91) hide show
  1. checksums.yaml +8 -8
  2. data/lib/{aboutyou-sdk/CacheProvider/Dalli.rb → AboutYou/CacheProvider/dalli.rb} +18 -19
  3. data/lib/{aboutyou-sdk/CacheProvider/Redis.rb → AboutYou/CacheProvider/redis.rb} +19 -20
  4. data/lib/{aboutyou-sdk/Criteria/ProductFields.rb → AboutYou/Criteria/product_fields.rb} +25 -27
  5. data/lib/{aboutyou-sdk/Criteria/ProductSearchCriteria.rb → AboutYou/Criteria/product_search_criteria.rb} +128 -123
  6. data/lib/{aboutyou-sdk/Factory/DefaultModelFactory.rb → AboutYou/Factory/default_model_factory.rb} +267 -224
  7. data/lib/AboutYou/Model/Basket/abstract_basket_item.rb +57 -0
  8. data/lib/AboutYou/Model/Basket/basket_item.rb +95 -0
  9. data/lib/AboutYou/Model/Basket/basket_set.rb +199 -0
  10. data/lib/AboutYou/Model/Basket/basket_set_item.rb +54 -0
  11. data/lib/AboutYou/Model/Basket/basket_variant_item.rb +123 -0
  12. data/lib/{aboutyou-sdk/Model/CategoryManager/DefaultCategoryManager.rb → AboutYou/Model/CategoryManager/default_category_manager.rb} +80 -65
  13. data/lib/{aboutyou-sdk/Model/FacetManager/DefaultFacetManager.rb → AboutYou/Model/FacetManager/default_facet_manager.rb} +58 -50
  14. data/lib/{aboutyou-sdk/Model/ProductSearchResult/FacetCount.rb → AboutYou/Model/ProductSearchResult/facet_count.rb} +2 -3
  15. data/lib/AboutYou/Model/ProductSearchResult/facet_counts.rb +67 -0
  16. data/lib/{aboutyou-sdk/Model/ProductSearchResult/PriceRange.rb → AboutYou/Model/ProductSearchResult/price_range.rb} +17 -18
  17. data/lib/AboutYou/Model/ProductSearchResult/sale_counts.rb +79 -0
  18. data/lib/AboutYou/Model/ProductSearchResult/terms_count.rb +40 -0
  19. data/lib/{aboutyou-sdk/Model/AbstractModel.rb → AboutYou/Model/abstract_model.rb} +2 -3
  20. data/lib/{aboutyou-sdk/Model/App.rb → AboutYou/Model/app.rb} +15 -15
  21. data/lib/{aboutyou-sdk/Model/Autocomplete.rb → AboutYou/Model/autocomplete.rb} +25 -32
  22. data/lib/AboutYou/Model/basket.rb +235 -0
  23. data/lib/AboutYou/Model/categories_result.rb +24 -0
  24. data/lib/AboutYou/Model/category.rb +102 -0
  25. data/lib/AboutYou/Model/category_tree.rb +37 -0
  26. data/lib/AboutYou/Model/facet.rb +86 -0
  27. data/lib/AboutYou/Model/facet_group.rb +96 -0
  28. data/lib/AboutYou/Model/facet_group_set.rb +209 -0
  29. data/lib/AboutYou/Model/image.rb +102 -0
  30. data/lib/{aboutyou-sdk/Model/ImageSize.rb → AboutYou/Model/image_size.rb} +9 -5
  31. data/lib/AboutYou/Model/initiate_order.rb +53 -0
  32. data/lib/AboutYou/Model/order.rb +22 -0
  33. data/lib/AboutYou/Model/product.rb +353 -0
  34. data/lib/AboutYou/Model/product_search_result.rb +114 -0
  35. data/lib/AboutYou/Model/products_ean_result.rb +43 -0
  36. data/lib/AboutYou/Model/products_result.rb +56 -0
  37. data/lib/AboutYou/Model/result_error.rb +28 -0
  38. data/lib/AboutYou/Model/variant.rb +214 -0
  39. data/lib/AboutYou/Model/variants_result.rb +91 -0
  40. data/lib/AboutYou/client.rb +128 -0
  41. data/lib/{aboutyou-sdk/Constants.rb → AboutYou/constants.rb} +3 -5
  42. data/lib/AboutYou/query.rb +343 -0
  43. data/lib/AboutYou/query_builder.rb +530 -0
  44. data/lib/ay.rb +566 -0
  45. data/tests/Sinatra-test/Main.rb +3 -0
  46. data/tests/testAutocomplete.rb +5 -6
  47. data/tests/testCatFilter.rb +8 -9
  48. data/tests/testCatTree.rb +3 -3
  49. data/tests/testCategoryCaching.rb +4 -5
  50. data/tests/{testFacetCaching.rb → testDalliCache.rb} +4 -5
  51. data/tests/testFacetTypes.rb +5 -6
  52. data/tests/testFacets.rb +7 -8
  53. data/tests/testFetchFacet.rb +5 -6
  54. data/tests/testJavaScript.rb +3 -4
  55. data/tests/testProdCatLongestPath.rb +7 -8
  56. data/tests/testProductSearchResult.rb +6 -7
  57. data/tests/testProductsByEans.rb +6 -7
  58. data/tests/testProductsByIds.rb +6 -7
  59. data/tests/testRedisCache.rb +4 -5
  60. data/tests/testSuggest.rb +5 -6
  61. data/tests/testVariantsByIds.rb +7 -8
  62. metadata +46 -46
  63. data/lib/aboutyou-sdk.rb +0 -596
  64. data/lib/aboutyou-sdk/Client.rb +0 -134
  65. data/lib/aboutyou-sdk/Model/Basket.rb +0 -268
  66. data/lib/aboutyou-sdk/Model/Basket/AbstractBasketItem.rb +0 -76
  67. data/lib/aboutyou-sdk/Model/Basket/BasketItem.rb +0 -100
  68. data/lib/aboutyou-sdk/Model/Basket/BasketSet.rb +0 -192
  69. data/lib/aboutyou-sdk/Model/Basket/BasketSetItem.rb +0 -46
  70. data/lib/aboutyou-sdk/Model/Basket/BasketVariantItem.rb +0 -137
  71. data/lib/aboutyou-sdk/Model/CategoriesResult.rb +0 -15
  72. data/lib/aboutyou-sdk/Model/Category.rb +0 -126
  73. data/lib/aboutyou-sdk/Model/CategoryTree.rb +0 -35
  74. data/lib/aboutyou-sdk/Model/Facet.rb +0 -105
  75. data/lib/aboutyou-sdk/Model/FacetGroup.rb +0 -110
  76. data/lib/aboutyou-sdk/Model/FacetGroupSet.rb +0 -242
  77. data/lib/aboutyou-sdk/Model/Image.rb +0 -134
  78. data/lib/aboutyou-sdk/Model/InitiateOrder.rb +0 -50
  79. data/lib/aboutyou-sdk/Model/Order.rb +0 -17
  80. data/lib/aboutyou-sdk/Model/Product.rb +0 -335
  81. data/lib/aboutyou-sdk/Model/ProductSearchResult.rb +0 -125
  82. data/lib/aboutyou-sdk/Model/ProductSearchResult/FacetCounts.rb +0 -59
  83. data/lib/aboutyou-sdk/Model/ProductSearchResult/SaleCounts.rb +0 -71
  84. data/lib/aboutyou-sdk/Model/ProductSearchResult/TermsCount.rb +0 -36
  85. data/lib/aboutyou-sdk/Model/ProductsEansResult.rb +0 -47
  86. data/lib/aboutyou-sdk/Model/ProductsResult.rb +0 -52
  87. data/lib/aboutyou-sdk/Model/ResultError.rb +0 -24
  88. data/lib/aboutyou-sdk/Model/Variant.rb +0 -255
  89. data/lib/aboutyou-sdk/Model/VariantsResult.rb +0 -102
  90. data/lib/aboutyou-sdk/Query.rb +0 -350
  91. data/lib/aboutyou-sdk/QueryBuilder.rb +0 -499
@@ -15,84 +15,86 @@ module AboutYou
15
15
  # the read-in categories from the category manager
16
16
  attr_accessor :categories
17
17
  # the parent child ids for the categories
18
- attr_accessor :parentChildIds
18
+ attr_accessor :parent_child_ids
19
19
  # the cache client
20
20
  attr_accessor :cache
21
21
  # the cache key for the app
22
- attr_accessor :cacheKey
22
+ attr_accessor :cache_key
23
23
  # instance of AY
24
- attr_accessor :shopApi
24
+ attr_accessor :shop_api
25
25
 
26
26
  ###
27
27
  # the Constructor for the AY class
28
28
  #
29
29
  # * *Args* :
30
30
  # - +cache+ -> The cache client set on the AY class
31
- # - +appId+ -> The App-Id of the App
32
- # - +shopApi+ -> an Instance of AY
31
+ # - +app_id+ -> The App-Id of the App
32
+ # - +shop_api+ -> an Instance of AY
33
33
  #
34
34
  # * *Returns* :
35
35
  # - Instance of AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager
36
36
  ###
37
- def initialize(cache = nil, appId = '', shopApi)
38
- self.categories = {}
39
- self.shopApi = shopApi
40
- self.cache = cache
41
- self.cacheKey = 'AY:SDK:' + String(appId) + ':categories'
42
- self.loadCachedCategories
37
+ def initialize(cache = nil, app_id = '', shop_api)
38
+ self.categories = {}
39
+ self.shop_api = shop_api
40
+ self.cache = cache
41
+ self.cache_key = 'AY:SDK:' + String(app_id) + ':categories'
42
+ load_cached_categories
43
43
  end
44
44
 
45
45
  ###
46
46
  # Gets the cached Categories for this app
47
- #
47
+ #
48
48
  # * *Returns* :
49
49
  # - True/False determining whether the loading was sucessfull or not
50
50
  ###
51
- def loadCachedCategories
52
- parseJson(self.cache.get(self.cacheKey), self.shopApi.modelFactoryInstance) if self.cache && self.cache.exists(self.cacheKey)
51
+ def load_cached_categories
52
+ parse_json(
53
+ cache.get(cache_key),
54
+ shop_api.model_factory_instance
55
+ ) if cache && cache.exists(cache_key)
53
56
  end
54
57
 
55
58
  ###
56
- # this method caches a given jsonObject
57
- #
59
+ # this method caches a given json_object
60
+ #
58
61
  # * *Args* :
59
- # - +jsonObject+ -> the jsonObject received from the api
62
+ # - +json_object+ -> the jsonObject received from the api
60
63
  #
61
64
  # * *Returns* :
62
65
  # - True/False determining whether the setting was sucessfull or not
63
66
  ###
64
- def cacheCategories(jsonObject)
65
- self.cache.set(self.cacheKey, jsonObject, DEFAULT_CACHE_DURATION)
67
+ def cache_categories(json_object)
68
+ cache.set(cache_key, json_object, DEFAULT_CACHE_DURATION)
66
69
  end
67
70
 
68
71
  ###
69
72
  # This method clears the cache
70
- #
73
+ #
71
74
  # * *Returns* :
72
75
  # - True/False determining whether the clearing was sucessfull or not
73
76
  ###
74
- def clearCache
75
- self.cache.delete(self.cacheKey)
77
+ def clear_cache
78
+ cache.delete(cache_key)
76
79
  end
77
80
 
78
81
  ###
79
- # this method parses a json object received from the api and
82
+ # this method parses a json object received from the api and
80
83
  # creates models from it
81
84
  #
82
85
  # * *Args* :
83
- # - +jsonObject+ -> the jsonObject received from the api
86
+ # - +json_object+ -> the jsonObject received from the api
84
87
  # - +factory+ -> the model factory used for creating the models
85
88
  #
86
89
  # * *Returns* :
87
90
  # - Instance of AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager
88
91
  ###
89
- def parseJson(jsonObject, factory)
90
- if jsonObject && self.categories.empty?
91
- self.cacheCategories(jsonObject) if self.cache
92
- self.parentChildIds = jsonObject["parent_child"]
93
- jsonObject["ids"].each do |id, jsonCategory|
94
- self.categories[id] = factory.createCategory(jsonCategory)
95
- end
92
+ def parse_json(json_object, factory)
93
+ return if !json_object && categories.empty?
94
+ cache_categories(json_object) if cache
95
+ self.parent_child_ids = json_object['parent_child']
96
+ json_object['ids'].each do |id, json_category|
97
+ categories[id] = factory.create_category(json_category)
96
98
  end
97
99
  end
98
100
 
@@ -103,26 +105,26 @@ module AboutYou
103
105
  # * *Returns* :
104
106
  # - a boolean which determines whether this Category Manager has read-in categories or not
105
107
  ###
106
- def isEmpty
107
- self.categories.empty?
108
+ def empty?
109
+ categories.empty?
108
110
  end
109
111
 
110
112
  ###
111
113
  # This method returns the root categories for the read-in categories
112
- #
114
+ #
113
115
  # * *Args* :
114
116
  # - +activeOnly+ -> determines whether the result should contain only active categories or not
115
117
  #
116
118
  # * *Returns* :
117
119
  # - a Hash containing pairs of Category_Id => instance of AboutYou::SDK::Model::Category
118
120
  ###
119
- def categoryTree(activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
120
- self.subcategories(0, activeOnly)
121
+ def category_tree(active_only = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
122
+ subcategories(0, active_only)
121
123
  end
122
124
 
123
125
  ###
124
126
  # This method is used for getting a category model by a given id
125
- #
127
+ #
126
128
  # * *Args* :
127
129
  # - +id+ -> the id for which a category model should be returned
128
130
  #
@@ -138,7 +140,7 @@ module AboutYou
138
140
  # This method is used for getting either all categories when +id+
139
141
  # is nil or a Hash of all Category Models found for an Array of
140
142
  # Category Ids
141
- #
143
+ #
142
144
  # * *Args* :
143
145
  # - +ids+ -> an Array of category Ids
144
146
  # - +activeOnly+ -> determines whether the result should contain only active categories or not
@@ -146,26 +148,30 @@ module AboutYou
146
148
  # * *Returns* :
147
149
  # - a Hash containing pairs of Category_ID => an Instance of AboutYou::SDK::Model::Category
148
150
  ###
149
- def categories(ids=nil, activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
150
- return @categories if ids == nil
151
+ def categories(
152
+ ids = nil,
153
+ active_only = AboutYou::SDK::Model::Category::ACTIVE_ONLY
154
+ )
155
+ return @categories if ids.nil?
151
156
  return {} unless @categories
152
157
 
153
158
  categories = {}
154
159
 
155
160
  ids.each do |id|
156
- if category(id)
157
- category = category(id)
158
- if activeOnly == AboutYou::SDK::Model::Category::ALL || category.isActive
159
- categories[id] = category
160
- end
161
- end
161
+ next unless category(id)
162
+ category = category(id)
163
+ next unless
164
+ active_only == AboutYou::SDK::Model::Category::ALL ||
165
+ category.is_active
166
+ categories[id] = category
162
167
  end
168
+
163
169
  categories
164
170
  end
165
171
 
166
172
  ###
167
173
  # This method gets the subcategories for a given category id
168
- #
174
+ #
169
175
  # * *Args* :
170
176
  # - +id+ -> an Array of category Ids
171
177
  # - +activeOnly+ -> determines whether the result should contain only active categories or not
@@ -173,14 +179,14 @@ module AboutYou
173
179
  # * *Returns* :
174
180
  # - a Hash containing pairs of Category_ID => an Instance of AboutYou::SDK::Model::Category
175
181
  ###
176
- def subcategories(id, activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
177
- return Array(nil) unless self.parentChildIds.key?(String(id))
178
- self.categories(self.parentChildIds[String(id)], activeOnly)
182
+ def subcategories(id, active_only = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
183
+ return [] unless parent_child_ids && parent_child_ids.key?(String(id))
184
+ categories(parent_child_ids[String(id)], active_only)
179
185
  end
180
186
 
181
187
  ###
182
188
  # This method gets the first category which has a certain name
183
- #
189
+ #
184
190
  # * *Args* :
185
191
  # - +name+ -> the name which should be found
186
192
  # - +activeOnly+ -> determines whether the result should contain only active categories or not
@@ -188,11 +194,15 @@ module AboutYou
188
194
  # * *Returns* :
189
195
  # - either an instance of AboutYou::SDK::Model::Category or nil if +name+ not found
190
196
  ###
191
- def firstCategoryByName(name, activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
192
- self.categories.each do |category|
193
- if category.name == name && (activeOnly == AboutYou::SDK::Model::Category::ACTIVE_ONLY || category.isActive)
194
- return category
195
- end
197
+ def first_category_by_name(
198
+ name,
199
+ active_only = AboutYou::SDK::Model::Category::ACTIVE_ONLY
200
+ )
201
+ categories.each do |category|
202
+ return category if
203
+ category.name == name &&
204
+ (active_only == AboutYou::SDK::Model::Category::ACTIVE_ONLY ||
205
+ category.is_active)
196
206
  end
197
207
 
198
208
  nil
@@ -200,7 +210,7 @@ module AboutYou
200
210
 
201
211
  ###
202
212
  # This method gets the subcategories for a given category id
203
- #
213
+ #
204
214
  # * *Args* :
205
215
  # - +id+ -> an Array of category Ids
206
216
  # - +activeOnly+ -> determines whether the result should contain only active categories or not
@@ -208,17 +218,22 @@ module AboutYou
208
218
  # * *Returns* :
209
219
  # - a Hash containing pairs of Category_ID => an Instance of AboutYou::SDK::Model::Category
210
220
  ###
211
- def categoriesByName(name, activeOnly = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
212
- resultCategories = []
213
- self.categories.each do |category|
214
- if category.name == name && (activeOnly == AboutYou::SDK::Model::Category::ALL || category.isActive)
215
- resultCategories.push(category)
216
- end
221
+ def categories_by_name(
222
+ name,
223
+ active_only = AboutYou::SDK::Model::Category::ACTIVE_ONLY
224
+ )
225
+ result_categories = []
226
+ categories.each do |category|
227
+ result_categories.push(category) if
228
+ category.name == name &&
229
+ (active_only == AboutYou::SDK::Model::Category::ALL ||
230
+ category.is_active)
217
231
  end
218
- resultCategories
232
+
233
+ result_categories
219
234
  end
220
235
  end
221
236
  end
222
237
  end
223
238
  end
224
- end
239
+ end
@@ -10,88 +10,90 @@ module AboutYou
10
10
  ###
11
11
  class DefaultFacetManager
12
12
  # the duration for the cached values to live
13
- DEFAULT_CACHE_DURATION = 7200;
13
+ DEFAULT_CACHE_DURATION = 7200
14
14
 
15
15
  # a Hash containing instances of AboutYou::SDK::Model::Facet
16
16
  attr_accessor :facets
17
17
  # an Instance of a class of AboutYou::SDK::CacheProvider
18
18
  attr_accessor :cache
19
19
  # The key for which the values are stored in the cache
20
- attr_accessor :cacheKey
20
+ attr_accessor :cache_key
21
21
  # an Instance of AY
22
- attr_accessor :shopApi
22
+ attr_accessor :shop_api
23
23
 
24
24
  ###
25
25
  # the Constructor for the DefaultFacetManager class
26
26
  #
27
27
  # * *Args* :
28
28
  # - +cache+ -> The cache client set on the AY class
29
- # - +appId+ -> The App-Id of the App
30
- # - +shopApi+ -> an Instance of AY
29
+ # - +app_id+ -> The App-Id of the App
30
+ # - +shop_api+ -> an Instance of AY
31
31
  #
32
32
  # * *Returns* :
33
33
  # - Instance of AboutYou::SDK::Model::CategoryManager::DefaultFacetManager
34
34
  ###
35
- def initialize(cache = nil, appId = '', shopApi)
36
- self.cache = cache
37
- self.facets = {}
38
- self.shopApi = shopApi
39
- self.cacheKey = 'AY:SDK:' + String(appId) + ':facets'
35
+ def initialize(cache = nil, app_id = '', shop_api)
36
+ self.cache = cache
37
+ self.facets = {}
38
+ self.shop_api = shop_api
39
+ self.cache_key = 'AY:SDK:' + String(app_id) + ':facets'
40
40
 
41
- self.loadCachedFacets
41
+ load_cached_facets
42
42
  end
43
43
 
44
44
  ###
45
45
  # Gets the cached Categories for this app
46
- #
46
+ #
47
47
  # * *Returns* :
48
48
  # - True/False determining whether the loading was sucessfull or not
49
49
  ###
50
- def loadCachedFacets
51
- parseJson(self.cache.get(self.cacheKey), self.shopApi.modelFactoryInstance) if self.cache && self.cache.exists(self.cacheKey)
50
+ def load_cached_facets
51
+ parse_json(
52
+ cache.get(cache_key),
53
+ shop_api.model_factory_instance
54
+ ) if cache && cache.exists(cache_key)
52
55
  end
53
-
56
+
54
57
  ###
55
- # this method caches a given jsonObject
56
- #
58
+ # this method caches a given json_object
59
+ #
57
60
  # * *Args* :
58
- # - +jsonObject+ -> the jsonObject received from the api
61
+ # - +json_object+ -> the jsonObject received from the api
59
62
  #
60
63
  # * *Returns* :
61
64
  # - True/False determining whether the setting was sucessfull or not
62
65
  ###
63
- def cacheFacets(jsonObject)
64
- self.cache.set(self.cacheKey, jsonObject, DEFAULT_CACHE_DURATION)
66
+ def cache_facets(json_object)
67
+ cache.set(cache_key, json_object, DEFAULT_CACHE_DURATION)
65
68
  end
66
-
69
+
67
70
  ###
68
71
  # This method clears the cache
69
- #
72
+ #
70
73
  # * *Returns* :
71
74
  # - True/False determining whether the clearing was sucessfull or not
72
75
  ###
73
- def clearCache
74
- self.cache.delete(self.cacheKey)
76
+ def clear_cache
77
+ cache.delete(cache_key)
75
78
  end
76
-
79
+
77
80
  ###
78
- # this method parses a json object received from the api and
81
+ # this method parses a json object received from the api and
79
82
  # creates models from it
80
83
  #
81
84
  # * *Args* :
82
- # - +jsonObject+ -> the jsonObject received from the api
85
+ # - +json_object+ -> the jsonObject received from the api
83
86
  # - +factory+ -> the model factory used for creating the models
84
87
  #
85
88
  # * *Returns* :
86
89
  # - Instance of AboutYou::SDK::Model::CategoryManager::DefaultFacetManager
87
90
  ###
88
- def parseJson(jsonObject, factory, query=nil)
89
- if self.facets.empty? && jsonObject
90
- self.cacheFacets(jsonObject) if self.cache
91
- self.facets = factory.createFacetsList(jsonObject, query)
92
- end
91
+ def parse_json(json_object, factory, query = nil)
92
+ return unless facets.empty? && json_object
93
+ cache_facets(json_object) if cache
94
+ self.facets = factory.create_facets_list(json_object, query)
93
95
  end
94
-
96
+
95
97
  ###
96
98
  # this method checks whether this facet manager has read-in
97
99
  # facets or not
@@ -99,40 +101,46 @@ module AboutYou
99
101
  # * *Returns* :
100
102
  # - a boolean which determines whether this facet Manager has read-in facets or not
101
103
  ###
102
- def isEmpty
103
- self.facets.empty?
104
+ def empty?
105
+ facets.empty?
104
106
  end
105
107
 
106
108
  ###
107
- # This method is used for getting a facet model by a given groupId and facetId
108
- #
109
+ # This method is used for getting a facet model by a given group_id and facetId
110
+ #
109
111
  # * *Args* :
110
- # - +groupId+ -> the group id for which a facet model should be returned
112
+ # - +group_id+ -> the group id for which a facet model should be returned
111
113
  # - +id+ -> the facet id for which a facet model should be returned
112
114
  #
113
115
  # * *Returns* :
114
- # - either an instance of AboutYou::SDK::Model::Facet or nil if +groupId+ or +id+ is not found
115
- ###
116
- def facet(groupId, id)
117
- lookupKey = AboutYou::SDK::Model::Facet.new(0, "", [], 0, "").uniqueKey(groupId, id);
118
- self.facets[lookupKey] ? self.facets[lookupKey] : nil
116
+ # - either an instance of AboutYou::SDK::Model::Facet or nil if +group_id+ or +id+ is not found
117
+ ###
118
+ def facet(group_id, id)
119
+ look_up_key = AboutYou::SDK::Model::Facet.new(
120
+ 0,
121
+ '',
122
+ [],
123
+ 0,
124
+ ''
125
+ ).unique_key(group_id, id)
126
+ facets[look_up_key] ? facets[look_up_key] : nil
119
127
  end
120
-
128
+
121
129
  ###
122
130
  # This method is used for getting all facets for an Array of group ids
123
- #
131
+ #
124
132
  # * *Args* :
125
- # - +groupIds+ -> an Array containing group ids for which facet models should be returned
133
+ # - +group_ids+ -> an Array containing group ids for which facet models should be returned
126
134
  #
127
135
  # * *Returns* :
128
136
  # - a Hash containing pairs of facetId => instance of AboutYou::SDK::Model::Facet
129
137
  ###
130
- def facetsByGroupIds(groupIds = [])
131
- groupIds = groupIds.map { |gId| Integer(gId) }
132
- self.facets.select { |key, facet| groupIds.include?(facet.groupId) }
138
+ def facets_by_group_ids(group_ids = [])
139
+ group_ids = group_ids.map { |gId| Integer(gId) }
140
+ facets.select { |_key, facet| group_ids.include?(facet.group_id) }
133
141
  end
134
142
  end
135
143
  end
136
144
  end
137
145
  end
138
- end
146
+ end