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
@@ -10,124 +10,137 @@ module AboutYou
10
10
  ###
11
11
  class DefaultModelFactory
12
12
  # The client which performs the api calls
13
- attr_accessor :shopApi
13
+ attr_accessor :shop_api
14
14
  # the category manager responsible for managing the categories
15
- attr_accessor :categoryManager
15
+ attr_accessor :category_manager
16
16
  # the facet manager responsible for managing the facets
17
- attr_accessor :facetManager
17
+ attr_accessor :facet_manager
18
18
 
19
19
  ###
20
20
  # Constructor for AboutYou::SDK::Factory::DefaultModelFactory
21
21
  #
22
22
  # * *Args* :
23
- # - +shopApi+ -> the client which should perform the api calls
24
- # - +categoryManager+ -> the category manager responsible for managing the categories
25
- # - +:facetManager+ -> the facet manager responsible for managing the facets
23
+ # - +shop_api+ -> the client which should perform the api calls
24
+ # - +category_manager+ -> the category manager responsible for managing the categories
25
+ # - +:facet_manager+ -> the facet manager responsible for managing the facets
26
26
  #
27
27
  # * *Returns* :
28
28
  # - an instance of AboutYou::SDK::Factory::DefaultModelFactory
29
29
  ###
30
- def initialize(shopApi = nil)
31
- self.shopApi = shopApi
30
+ def initialize(shop_api = nil)
31
+ self.shop_api = shop_api
32
32
  end
33
-
34
- def initializeManagers(facetManager, categoryManager)
35
- self.categoryManager = categoryManager
36
- self.facetManager = facetManager
37
- AboutYou::SDK::Model::FacetGroupSet.facetManager = self.facetManager
33
+
34
+ def initialize_managers(facet_manager, category_manager)
35
+ self.category_manager = category_manager
36
+ self.facet_manager = facet_manager
37
+ AboutYou::SDK::Model::FacetGroupSet.facet_manager = self.facet_manager
38
38
  end
39
39
 
40
40
  ###
41
41
  # sets the baseimage url for the image model
42
42
  #
43
43
  # * *Args* :
44
- # - +baseUrl+ -> the url which should be used by the image model
44
+ # - +base_url+ -> the url which should be used by the image model
45
45
  ###
46
- def baseImageUrl=(baseUrl)
47
- AboutYou::SDK::Model::Image.baseUrl=baseUrl
46
+ def base_image_url=(base_url)
47
+ AboutYou::SDK::Model::Image.base_url = base_url
48
48
  end
49
49
 
50
50
  ###
51
51
  # creates an autocomplete model
52
52
  #
53
53
  # * *Args* :
54
- # - +jsonObject+ -> the api response in json format
54
+ # - +json_object+ -> the api response in json format
55
55
  # - +query+ -> the query sent to the api
56
- #
56
+ #
57
57
  # * *Returns* :
58
58
  # - an instance of AboutYou::SDK::Model::Autocomplete
59
59
  ###
60
- def createAutocomplete(jsonObject, query)
61
- AboutYou::SDK::Model::Autocomplete.createFromJson(jsonObject, self)
60
+ def create_autocomplete(json_object, _query)
61
+ AboutYou::SDK::Model::Autocomplete.create_from_json(json_object, self)
62
62
  end
63
63
 
64
64
  ###
65
65
  # creates a basket model
66
66
  #
67
67
  # * *Args* :
68
- # - +jsonObject+ -> the api response in json format
68
+ # - +json_object+ -> the api response in json format
69
69
  # - +query+ -> the query sent to the api
70
- #
70
+ #
71
71
  # * *Returns* :
72
72
  # - an instance of AboutYou::SDK::Model::Basket
73
73
  ###
74
- def createBasket(jsonObject, query)
75
- AboutYou::SDK::Model::Basket.createFromJson(jsonObject, self)
74
+ def create_basket(json_object, _query)
75
+ AboutYou::SDK::Model::Basket.create_from_json(json_object, self)
76
76
  end
77
77
 
78
78
  ###
79
79
  # creates a basket item model
80
80
  #
81
81
  # * *Args* :
82
- # - +jsonObject+ -> the api response in json format
82
+ # - +json_object+ -> the api response in json format
83
83
  # - +products+ -> the product models for which items should be created
84
- #
84
+ #
85
85
  # * *Returns* :
86
86
  # - an instance of AboutYou::SDK::Model::BasketItem
87
87
  ###
88
- def createBasketItem(jsonObject, products)
89
- AboutYou::SDK::Model::Basket::BasketItem.createFromJson(jsonObject, products)
88
+ def create_basket_item(json_object, products)
89
+ AboutYou::SDK::Model::Basket::BasketItem.create_from_json(
90
+ json_object,
91
+ products
92
+ )
90
93
  end
91
94
 
92
95
  ###
93
96
  # creates a basket set model
94
97
  #
95
98
  # * *Args* :
96
- # - +jsonObject+ -> the api response in json format
99
+ # - +json_object+ -> the api response in json format
97
100
  # - +products+ -> the product models for which items should be created
98
- #
101
+ #
99
102
  # * *Returns* :
100
103
  # - an instance of AboutYou::SDK::Model::BasketSet
101
104
  ###
102
- def createBasketSet(jsonObject, products)
103
- AboutYou::SDK::Model::BasketSet::createFromJson(jsonObject, self, products)
105
+ def create_basket_set(json_object, products)
106
+ AboutYou::SDK::Model::BasketSet.create_from_json(
107
+ json_object,
108
+ self,
109
+ products
110
+ )
104
111
  end
105
112
 
106
113
  ###
107
114
  # creates a basket setitem model
108
115
  #
109
116
  # * *Args* :
110
- # - +jsonObject+ -> the api response in json format
117
+ # - +json_object+ -> the api response in json format
111
118
  # - +products+ -> the product models for which items should be created
112
- #
119
+ #
113
120
  # * *Returns* :
114
121
  # - an instance of AboutYou::SDK::Model::BasketSetItem
115
122
  ###
116
- def createBasketSetItem(jsonObject, products)
117
- AboutYou::SDK::Model::BasketSetItem::createFromJson(jsonObject, products);
123
+ def create_basket_set_item(json_object, products)
124
+ AboutYou::SDK::Model::BasketSetItem.create_from_json(
125
+ json_object,
126
+ products
127
+ )
118
128
  end
119
129
 
120
130
  ###
121
131
  # creates a category model
122
132
  #
123
133
  # * *Args* :
124
- # - +jsonObject+ -> the api response in json format
125
- #
134
+ # - +json_object+ -> the api response in json format
135
+ #
126
136
  # * *Returns* :
127
137
  # - an instance of AboutYou::SDK::Model::Category
128
138
  ###
129
- def createCategory(jsonObject)
130
- AboutYou::SDK::Model::Category.createFromJson(jsonObject, self.categoryManager)
139
+ def create_category(json_object)
140
+ AboutYou::SDK::Model::Category.create_from_json(
141
+ json_object,
142
+ category_manager
143
+ )
131
144
  end
132
145
 
133
146
  ###
@@ -135,27 +148,27 @@ module AboutYou
135
148
  #
136
149
  # * *Args* :
137
150
  # - +jsonArray+ -> an Array containing the api response
138
- # - +query+ -> the query sent to the api
139
- #
151
+ # - +_query+ -> the _query sent to the api
152
+ #
140
153
  # * *Returns* :
141
154
  # - an instance of AboutYou::SDK::Model::CategoryTree
142
155
  ###
143
- def createCategoryTree(jsonArray, query)
144
- self.initializeCategoryManager(jsonArray)
145
- AboutYou::SDK::Model::CategoryTree.new(self.categoryManager)
156
+ def create_category_tree(json_array, _query)
157
+ initialize_category_manager(json_array)
158
+ AboutYou::SDK::Model::CategoryTree.new(category_manager)
146
159
  end
147
160
 
148
161
  ###
149
162
  # creates a facet model
150
163
  #
151
164
  # * *Args* :
152
- # - +jsonObject+ -> the api response in json format
153
- #
165
+ # - +json_object+ -> the api response in json format
166
+ #
154
167
  # * *Returns* :
155
168
  # - an instance of AboutYou::SDK::Model::Facet
156
169
  ###
157
- def createFacet(jsonObject)
158
- AboutYou::SDK::Model::Facet.createFromJson(jsonObject)
170
+ def create_facet(json_object)
171
+ AboutYou::SDK::Model::Facet.create_from_json(json_object)
159
172
  end
160
173
 
161
174
  ###
@@ -164,15 +177,15 @@ module AboutYou
164
177
  #
165
178
  # * *Args* :
166
179
  # - +jsonArray+ -> an Array containing the api response
167
- #
180
+ #
168
181
  # * *Returns* :
169
182
  # - a Hash containing pairs of facetKey => AboutYou::SDK::Model::Facet
170
183
  ###
171
- def createFacetList(jsonArray, query)
184
+ def create_facet_list(json_array, _query)
172
185
  facets = {}
173
- jsonArray.each do |jsonFacet|
174
- facet = self.createFacet(jsonFacet)
175
- key = facet.uniqueKey
186
+ json_array.each do |json_facet|
187
+ facet = create_facet(json_facet)
188
+ key = facet.unique_key
176
189
  facets[key] = facet
177
190
  end
178
191
 
@@ -184,142 +197,151 @@ module AboutYou
184
197
  # facetKey => AboutYou::SDK::Model::Facet
185
198
  #
186
199
  # * *Args* :
187
- # - +jsonObject+ -> the api response in json format
200
+ # - +json_object+ -> the api response in json format
188
201
  # - +query+ -> the query sent to the api
189
- #
202
+ #
190
203
  # * *Returns* :
191
204
  # - a Hash containing pairs of facetKey => AboutYou::SDK::Model::Facet
192
205
  ###
193
- def createFacetsList(jsonObject, query=nil)
194
- self.createFacetList(jsonObject["facet"], query)
206
+ def create_facets_list(json_object, query = nil)
207
+ create_facet_list(json_object['facet'], query)
195
208
  end
196
-
197
209
 
198
210
  ###
199
211
  # creates a Hash containing one or multiple pairs of
200
212
  # group_id => instance of AboutYou::SDK::Model::FacetCounts
201
213
  #
202
214
  # * *Args* :
203
- # - +jsonObject+ -> the api response in json format
204
- #
215
+ # - +json_object+ -> the api response in json format
216
+ #
205
217
  # * *Returns* :
206
218
  # - a Hash containing pairs of group_id => instance of AboutYou::SDK::Model::FacetCounts
207
219
  ###
208
- def createFacetsCounts(jsonObject)
209
- facetsCounts = {}
220
+ def create_facets_counts(json_object)
221
+ facets_counts = {}
210
222
 
211
- jsonObject["facets"].each do |groupId, jsonResultFacet|
212
- unless groupId[/\d/]
213
- next
214
- end
215
- facetCounts = self.termFacets(groupId, jsonResultFacet["terms"])
216
- facetsCounts[groupId] = AboutYou::SDK::Model::FacetCounts.createFromJson(
217
- groupId,
218
- jsonResultFacet,
219
- facetCounts
223
+ json_object['facets'].each do |group_id, json_result_facet|
224
+ next unless group_id[/\d/]
225
+
226
+ facet_counts = term_facets(
227
+ group_id,
228
+ json_result_facet['terms']
220
229
  )
230
+ facets_counts[group_id] =
231
+ AboutYou::SDK::Model::FacetCounts.create_from_json(
232
+ group_id,
233
+ json_result_facet,
234
+ facet_counts
235
+ )
221
236
  end
222
237
 
223
- facetsCounts
238
+ facets_counts
224
239
  end
225
-
240
+
226
241
  ###
227
242
  # creates an Array containing one or multiple instances of
228
243
  # AboutYou::SDK::Model::FacetCount
229
244
  #
230
245
  # * *Args* :
231
- # - +groupId+ -> the group id of the facets
246
+ # - +group_id+ -> the group id of the facets
232
247
  # - +jsonTerms+ -> the single facet terms in json format
233
- #
248
+ #
234
249
  # * *Returns* :
235
250
  # - an Array containing instances of AboutYou::SDK::Model::FacetCount
236
251
  ###
237
- def termFacets(groupId, jsonTerms)
238
- facetCounts = []
239
- jsonTerms.each do |jsonTerm|
240
- id = Integer(jsonTerm["term"])
241
- facet = self.facetManager.facet(groupId, id)
242
- unless facet
243
- next
244
- end
252
+ def term_facets(group_id, json_terms)
253
+ facet_counts = []
254
+ json_terms.each do |json_term|
255
+ id = Integer(json_term['term'])
256
+ facet = facet_manager.facet(group_id, id)
257
+ next unless facet
258
+
245
259
  # TODO: Handle error, write test
246
- facetCounts.push(AboutYou::SDK::Model::FacetCount.new(facet, jsonTerm["count"]))
260
+ facet_counts.push(AboutYou::SDK::Model::FacetCount.new(
261
+ facet,
262
+ json_term['count']
263
+ )
264
+ )
247
265
  end
248
266
 
249
- facetCounts
250
- end
251
-
267
+ facet_counts
268
+ end
269
+
252
270
  ###
253
271
  # creates an Array containing all facet types available
254
272
  #
255
273
  # * *Args* :
256
274
  # - +jsonArray+ -> an Array containing the api response
257
- # - +query+ -> the query sent to the api
258
- #
275
+ # - +_query+ -> the _query sent to the api
276
+ #
259
277
  # * *Returns* :
260
278
  # - an Array containing all facet types available
261
279
  ###
262
- def createFacetTypes(jsonArray, query)
263
- jsonArray
280
+ def create_facet_types(json_array, _query)
281
+ json_array
264
282
  end
265
283
 
266
284
  ###
267
285
  # creates an image model
268
286
  #
269
287
  # * *Args* :
270
- # - +jsonObject+ -> the api response in json format
271
- #
288
+ # - +json_object+ -> the api response in json format
289
+ #
272
290
  # * *Returns* :
273
291
  # - an instance of AboutYou::SDK::Model::Image
274
292
  ###
275
- def createImage(jsonObject)
276
- AboutYou::SDK::Model::Image.createFromJson(jsonObject)
293
+ def create_image(json_object)
294
+ AboutYou::SDK::Model::Image.create_from_json(json_object)
277
295
  end
278
296
 
279
297
  ###
280
298
  # creates a product model
281
299
  #
282
300
  # * *Args* :
283
- # - +jsonObject+ -> the api response in json format
284
- #
301
+ # - +json_object+ -> the api response in json format
302
+ #
285
303
  # * *Returns* :
286
304
  # - an instance of AboutYou::SDK::Model::Product
287
305
  ###
288
- def createProduct(jsonObject)
289
- AboutYou::SDK::Model::Product.createFromJson(jsonObject, self, self.shopApi.appId)
306
+ def create_product(json_object)
307
+ AboutYou::SDK::Model::Product.create_from_json(
308
+ json_object,
309
+ self,
310
+ shop_api.app_id
311
+ )
290
312
  end
291
313
 
292
314
  ###
293
315
  # creates a variants result model
294
316
  #
295
317
  # * *Args* :
296
- # - +jsonObject+ -> the api response in json format
297
- # - +query+ -> the query sent to the api
298
- #
318
+ # - +json_object+ -> the api response in json format
319
+ # - +_query+ -> the _query sent to the api
320
+ #
299
321
  # * *Returns* :
300
322
  # - an instance of AboutYou::SDK::Model::VariantsResult
301
323
  ###
302
- def createVariantsResult(jsonObject, query)
324
+ def create_variants_result(json_object, _query)
303
325
  variants = {}
304
326
  errors = []
305
- productIds = []
306
- productSearchResult = false
327
+ product_ids = []
328
+ product_search_result = false
307
329
 
308
- jsonObject.each do |id, data|
309
- if data["error_code"]
330
+ json_object.each do |id, data|
331
+ if data['error_code']
310
332
  errors.push(id)
311
333
  else
312
- variants[data["id"]] = data["product_id"]
313
- productIds.push(data["product_id"])
334
+ variants[data['id']] = data['product_id']
335
+ product_ids.push(data['product_id'])
314
336
  end
315
337
  end
316
338
 
317
- if productIds.count > 0
318
- productIds = productIds.uniq
339
+ if product_ids.count > 0
340
+ product_ids = product_ids.uniq
319
341
  # search products for valid variants
320
- productSearchResult = self.shopApi.
321
- fetchProductsByIds(
322
- productIds, [
342
+
343
+ product_search_result = shop_api.fetch_products_by_ids(
344
+ product_ids, [
323
345
  AboutYou::SDK::Criteria::ProductFields::ATTRIBUTES_MERGED,
324
346
  AboutYou::SDK::Criteria::ProductFields::BRAND,
325
347
  AboutYou::SDK::Criteria::ProductFields::CATEGORIES,
@@ -335,152 +357,173 @@ module AboutYou
335
357
  ]
336
358
  )
337
359
  end
338
-
339
- AboutYou::SDK::Model::VariantsResult.create(variants, errors, productSearchResult)
360
+
361
+ AboutYou::SDK::Model::VariantsResult.create(
362
+ variants,
363
+ errors,
364
+ product_search_result
365
+ )
340
366
  end
341
367
 
342
368
  ###
343
369
  # creates a single product model
344
- #
370
+ #
345
371
  # * *Args* :
346
- # - +jsonObject+ -> the api response in json format
347
- #
372
+ # - +json_object+ -> the api response in json format
373
+ #
348
374
  # * *Returns* :
349
375
  # - an instance of AboutYou::SDK::Model::Product
350
376
  ###
351
- def createSingleProduct(jsonObject)
352
- self.createProduct(jsonObject)
377
+ def create_single_product(json_object)
378
+ createProduct(json_object)
353
379
  end
354
380
 
355
381
  ###
356
382
  # creates a products result model
357
- #
383
+ #
358
384
  # * *Args* :
359
- # - +jsonObject+ -> the api response in json format
360
- # - +query+ -> the query sent to the api
361
- #
385
+ # - +json_object+ -> the api response in json format
386
+ # - +_query+ -> the _query sent to the api
387
+ #
362
388
  # * *Returns* :
363
389
  # - an instance of AboutYou::SDK::Model::ProductsResult
364
390
  ###
365
- def createProductsResult(jsonObject, query)
366
- AboutYou::SDK::Model::ProductsResult.createFromJson(jsonObject, self)
391
+ def create_products_result(json_object, _query)
392
+ AboutYou::SDK::Model::ProductsResult.create_from_json(
393
+ json_object,
394
+ self
395
+ )
367
396
  end
368
397
 
369
398
  ###
370
399
  # creates a products eanresult model
371
- #
400
+ #
372
401
  # * *Args* :
373
- # - +jsonObject+ -> the api response in json format
374
- # - +query+ -> the query sent to the api
375
- #
402
+ # - +json_object+ -> the api response in json format
403
+ # - +_query+ -> the _query sent to the api
404
+ #
376
405
  # * *Returns* :
377
406
  # - an instance of AboutYou::SDK::Model::ProductsEanResult
378
407
  ###
379
- def createProductsEansResult(jsonObject, query)
380
- AboutYou::SDK::Model::ProductsEansResult.createFromJson(jsonObject, self)
408
+ def create_products_ean_result(json_object, _query)
409
+ AboutYou::SDK::Model::ProductsEansResult.create_from_json(
410
+ json_object,
411
+ self
412
+ )
381
413
  end
382
414
 
383
415
  ###
384
416
  # creates a product searchresult model
385
- #
417
+ #
386
418
  # * *Args* :
387
- # - +jsonObject+ -> the api response in json format
388
- # - +query+ -> the query sent to the api
389
- #
419
+ # - +json_object+ -> the api response in json format
420
+ # - +_query+ -> the _query sent to the api
421
+ #
390
422
  # * *Returns* :
391
423
  # - an instance of AboutYou::SDK::Model::ProductSearchResult
392
424
  ###
393
- def createProductSearchResult(jsonObject, query)
394
- return AboutYou::SDK::Model::ProductSearchResult.createFromJson(jsonObject, self)
425
+ def create_product_search_result(json_object, _query)
426
+ AboutYou::SDK::Model::ProductSearchResult.create_from_json(
427
+ json_object,
428
+ self
429
+ )
395
430
  end
396
431
 
397
432
  ###
398
433
  # creates a categories result model
399
- #
434
+ #
400
435
  # * *Args* :
401
- # - +jsonObject+ -> the api response in json format
436
+ # - +json_object+ -> the api response in json format
402
437
  # - +query+ -> the query sent to the api
403
- #
438
+ #
404
439
  # * *Returns* :
405
440
  # - an instance of AboutYou::SDK::Model::CategoriesResult
406
441
  ###
407
- def createCategoriesResult(jsonObject, query)
408
- AboutYou::SDK::Model::CategoriesResult.createFromJson(jsonObject, query["ids"], self)
442
+ def create_categories_result(json_object, query)
443
+ AboutYou::SDK::Model::CategoriesResult.create_from_json(
444
+ json_object,
445
+ query['ids'],
446
+ self
447
+ )
409
448
  end
410
449
 
411
450
  ###
412
451
  # creates an Array containing suggests
413
- #
452
+ #
414
453
  # * *Args* :
415
454
  # - +jsonArray+ -> an Array with the api response
416
- # - +query+ -> the query sent to the api
417
- #
455
+ # - +_query+ -> the _query sent to the api
456
+ #
418
457
  # * *Returns* :
419
458
  # - an Array containing suggests
420
459
  ###
421
- def createSuggest(jsonArray, query)
460
+ def create_suggest(jsonArray, _query)
422
461
  jsonArray
423
462
  end
424
463
 
425
464
  ###
426
465
  # creates a variant model
427
- #
466
+ #
428
467
  # * *Args* :
429
- # - +jsonObject+ -> the api response in json format
468
+ # - +json_object+ -> the api response in json format
430
469
  # - +product+ -> the product of the variant which should be created
431
- #
470
+ #
432
471
  # * *Returns* :
433
472
  # - an instance of AboutYou::SDK::Model::Variant
434
473
  ###
435
- def createVariant(jsonObject, product)
436
- AboutYou::SDK::Model::Variant.createFromJson(jsonObject, self, product)
474
+ def create_variant(json_object, product)
475
+ AboutYou::SDK::Model::Variant.create_from_json(
476
+ json_object,
477
+ self,
478
+ product
479
+ )
437
480
  end
438
481
 
439
482
  ###
440
483
  # creates an order model
441
- #
484
+ #
442
485
  # * *Args* :
443
- # - +jsonObject+ -> the api response in json format
444
- # - +query+ -> the query sent to the api
445
- #
486
+ # - +json_object+ -> the api response in json format
487
+ # - +_query+ -> the _query sent to the api
488
+ #
446
489
  # * *Returns* :
447
490
  # - an instance of AboutYou::SDK::Model::Order
448
491
  ###
449
- def createOrder(jsonObject, query)
450
- basket = self.createBasket(jsonObject["basket"])
492
+ def create_order(json_object, _query)
493
+ basket = create_basket(json_object['basket'])
451
494
 
452
- AboutYou::SDK::Model::Order.new(jsonObject["order_id"], basket);
495
+ AboutYou::SDK::Model::Order.new(json_object['order_id'], basket)
453
496
  end
454
497
 
455
498
  ###
456
499
  # creates an initiate order model
457
- #
500
+ #
458
501
  # * *Args* :
459
- # - +jsonObject+ -> the api response in json format
460
- # - +query+ -> the query sent to the api
461
- #
502
+ # - +json_object+ -> the api response in json format
503
+ # - +_query+ -> the _query sent to the api
504
+ #
462
505
  # * *Returns* :
463
506
  # - an instance of AboutYou::SDK::Model::InitiateOrder
464
507
  ###
465
- def initiateOrder(jsonObject, query)
466
- AboutYou::SDK::Model::InitiateOrder.createFromJson(jsonObject)
508
+ def initiate_order(json_object, _query)
509
+ AboutYou::SDK::Model::InitiateOrder.create_from_json(json_object)
467
510
  end
468
511
 
469
512
  ###
470
513
  # creates a Has containing one or multiple pairs of
471
514
  # app_id => instance of AboutYou::SDK::Model::App
472
- #
515
+ #
473
516
  # * *Args* :
474
- # - +jsonObject+ -> the api response in json format
475
- # - +query+ -> the query sent to the api
476
- #
517
+ # - +json_object+ -> the api response in json format
518
+ # - +_query+ -> the _query sent to the api
519
+ #
477
520
  # * *Returns* :
478
521
  # - a Hash containing pairs of app_id => instance of AboutYou::SDK::Model::App
479
522
  ###
480
- def createChildApps(jsonObject, query)
523
+ def create_child_apps(json_object, _query)
481
524
  apps = {}
482
- jsonObject["child_apps"].each do |jsonApp|
483
- app = self.createApp(jsonApp)
525
+ json_object['child_apps'].each do |json_app|
526
+ app = create_app(json_app)
484
527
  apps[app.id] = app
485
528
  end
486
529
 
@@ -489,112 +532,112 @@ module AboutYou
489
532
 
490
533
  ###
491
534
  # creates an app model
492
- #
535
+ #
493
536
  # * *Args* :
494
- # - +jsonObject+ -> the api response in json format
495
- #
537
+ # - +json_object+ -> the api response in json format
538
+ #
496
539
  # * *Returns* :
497
540
  # - an instance of AboutYou::SDK::Model::App
498
541
  ###
499
- def createApp(jsonObject)
500
- AboutYou::SDK::Model::App.createFromJson(jsonObject)
542
+ def create_app(json_object)
543
+ AboutYou::SDK::Model::App.create_from_json(json_object)
501
544
  end
502
545
 
503
546
  ###
504
547
  # this methods initiates the category manager
505
- #
548
+ #
506
549
  # * *Args* :
507
- # - +jsonObject+ -> the api response in json format
550
+ # - +json_object+ -> the api response in json format
508
551
  ###
509
- def initializeCategoryManager(jsonObject)
510
- self.categoryManager.parseJson(jsonObject, self)
552
+ def initialize_category_manager(json_object)
553
+ category_manager.parse_json(json_object, self)
511
554
  end
512
-
555
+
513
556
  ###
514
557
  # this methods updates the facet manager
515
- #
558
+ #
516
559
  # * *Args* :
517
- # - +jsonObject+ -> the api response in json format
560
+ # - +json_object+ -> the api response in json format
518
561
  # - +query+ -> the query sent to the api
519
562
  ###
520
- def updateFacetManager(jsonObject, query)
521
- self.facetManager.parseJson(jsonObject, self, query)
563
+ def update_facet_manager(json_object, query)
564
+ facet_manager.parse_json(json_object, self, query)
522
565
  end
523
566
 
524
567
  ###
525
568
  # this method creates a price range model
526
- #
569
+ #
527
570
  # * *Args* :
528
- # - +jsonObject+ -> the api response in json format
529
- #
571
+ # - +json_object+ -> the api response in json format
572
+ #
530
573
  # * *Returns* :
531
574
  # - an Array containing instances of AboutYou::SDK::Model::PriceRange
532
575
  ###
533
- def createPriceRanges(jsonObject)
534
- priceRanges = []
535
- jsonObject["ranges"].each do |range|
536
- priceRanges.push(AboutYou::SDK::Model::PriceRange.createFromJson(range))
576
+ def create_price_ranges(json_object)
577
+ price_ranges = []
578
+ json_object['ranges'].each do |range|
579
+ price_ranges.push(
580
+ AboutYou::SDK::Model::PriceRange.create_from_json(
581
+ range
582
+ )
583
+ )
537
584
  end
538
- priceRanges
585
+
586
+ price_ranges
539
587
  end
540
588
 
541
589
  ###
542
590
  # this method creates a sale counts model
543
- #
591
+ #
544
592
  # * *Args* :
545
- # - +jsonObject+ -> the api response in json format
546
- #
593
+ # - +json_object+ -> the api response in json format
594
+ #
547
595
  # * *Returns* :
548
596
  # - an instance of AboutYou::SDK::Model::SaleCounts
549
597
  ###
550
- def createSaleFacet(jsonObject)
551
- AboutYou::SDK::Model::SaleCounts.createFromJson(jsonObject)
598
+ def create_sale_facet(json_object)
599
+ AboutYou::SDK::Model::SaleCounts.create_from_json(json_object)
552
600
  end
553
601
 
554
602
  ###
555
603
  # this method creates the facets for given categories
556
- #
604
+ #
557
605
  # * *Args* :
558
606
  # - +jsonArray+ -> an Array containing the Api response
559
- #
607
+ #
560
608
  # * *Returns* :
561
609
  # - a Hash containing pairs of category_id => category
562
610
  ###
563
- def createCategoriesFacets(jsonArray)
564
- categoryManager =self.categoryManager
611
+ def create_categories_facets(json_array)
612
+ category_manager = self.category_manager
565
613
 
566
- flattenCategories = {}
567
- jsonArray.each do |item|
568
- id = item["term"]
569
- category = categoryManager.category(id)
614
+ flatten_categories = {}
615
+ json_array.each do |item|
616
+ id = item['term']
617
+ category = category_manager.category(id)
570
618
  next unless category
571
619
 
572
- category.productCount = item["count"]
573
- flattenCategories[id] = category
620
+ category.product_count = item['count']
621
+ flatten_categories[id] = category
574
622
  end
575
623
 
576
- flattenCategories
624
+ flatten_categories
577
625
  end
578
-
626
+
579
627
  ###
580
628
  # this method tries to handle errors which are received from the api
581
- #
629
+ #
582
630
  # * *Args* :
583
631
  # - +json+ -> the api response in json format
584
632
  # - +resultKey+ -> the result key received from the api
585
633
  # - +isMultiRequest+ -> determines whether the api-request was multiquery or not
586
634
  ###
587
- def preHandleError(json, resultKey, isMultiRequest)
588
- if resultKey == 'basket' && json["order_lines"]
589
- return false
590
- end
635
+ def pre_handle_error(json, result_key, is_multi_request)
636
+ return false if result_key == 'basket' && json['order_lines']
591
637
 
592
- if isMultiRequest
593
- raise 'ResultError!' + json
594
- end
595
- raise 'ResultError!' + json
638
+ fail 'ResultError!' + json + is_multi_request
596
639
  end
597
640
  end
598
641
  end
599
- end
600
- end
642
+ end
643
+ end