aboutyou-sdk 0.0.29 → 0.0.30

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.
Files changed (39) hide show
  1. checksums.yaml +8 -8
  2. data/lib/AboutYou/CacheProvider/dalli.rb +3 -0
  3. data/lib/AboutYou/Criteria/product_fields.rb +3 -0
  4. data/lib/AboutYou/Criteria/product_search_criteria.rb +8 -8
  5. data/lib/AboutYou/Factory/default_model_factory.rb +15 -2
  6. data/lib/AboutYou/Model/Basket/abstract_basket_item.rb +25 -20
  7. data/lib/AboutYou/Model/Basket/basket_item.rb +27 -27
  8. data/lib/AboutYou/Model/Basket/basket_set.rb +60 -62
  9. data/lib/AboutYou/Model/Basket/basket_set_item.rb +8 -9
  10. data/lib/AboutYou/Model/Basket/basket_variant_item.rb +55 -21
  11. data/lib/AboutYou/Model/ProductSearchResult/facet_count.rb +0 -2
  12. data/lib/AboutYou/Model/ProductSearchResult/price_range.rb +2 -2
  13. data/lib/AboutYou/Model/abstract_model.rb +5 -3
  14. data/lib/AboutYou/Model/app.rb +0 -2
  15. data/lib/AboutYou/Model/autocomplete.rb +0 -2
  16. data/lib/AboutYou/Model/basket.rb +91 -19
  17. data/lib/AboutYou/Model/brand.rb +8 -4
  18. data/lib/AboutYou/Model/categories_result.rb +13 -2
  19. data/lib/AboutYou/Model/category.rb +45 -19
  20. data/lib/AboutYou/Model/category_tree.rb +21 -7
  21. data/lib/AboutYou/Model/facet.rb +44 -22
  22. data/lib/AboutYou/Model/facet_group.rb +55 -21
  23. data/lib/AboutYou/Model/facet_group_set.rb +106 -23
  24. data/lib/AboutYou/Model/image.rb +36 -25
  25. data/lib/AboutYou/Model/image_size.rb +8 -5
  26. data/lib/AboutYou/Model/initiate_order.rb +26 -7
  27. data/lib/AboutYou/Model/order.rb +12 -2
  28. data/lib/AboutYou/Model/product.rb +261 -5
  29. data/lib/AboutYou/Model/product_search_result.rb +40 -10
  30. data/lib/AboutYou/Model/{products_ean_result.rb → products_eans_result.rb} +11 -5
  31. data/lib/AboutYou/Model/products_result.rb +13 -14
  32. data/lib/AboutYou/Model/result_error.rb +18 -2
  33. data/lib/AboutYou/Model/variant.rb +87 -26
  34. data/lib/AboutYou/Model/variants_result.rb +31 -15
  35. data/lib/AboutYou/client.rb +7 -0
  36. data/lib/AboutYou/query.rb +7 -2
  37. data/lib/AboutYou/query_builder.rb +22 -3
  38. data/lib/aboutyou-sdk.rb +7 -0
  39. metadata +3 -3
@@ -2,29 +2,47 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents a product search result model
7
- #
8
6
  ###
9
7
  class ProductSearchResult
8
+ # Array of instances of AboutYou::SDK::Model::Product
10
9
  attr_accessor :products
10
+ # String page hash
11
11
  attr_accessor :page_hash
12
+ # Integer count of products
12
13
  attr_accessor :product_count
14
+ # Integer count of products in sale
13
15
  attr_accessor :sale_counts
16
+ # Array containing instances of AboutYou::SDK::Model::PriceRange
14
17
  attr_accessor :price_ranges
18
+ # Array containing instances of AboutYou::SDK::Model::Facet
15
19
  attr_accessor :facets
20
+ # Array containing instances of AboutYou::SDK::Model::Category
16
21
  attr_accessor :categories
22
+ # raw facets
17
23
  attr_accessor :raw_facets
18
24
 
25
+ ###
26
+ # Constructor for the AboutYou::SDK::Model::ProductSearchResult class
27
+ #
28
+ # * *Returns* :
29
+ # - an instance of AboutYou::SDK::Model::ProductSearchResult
30
+ ###
19
31
  def initialize
20
32
  self.products = {}
33
+
34
+ self
21
35
  end
22
36
 
23
37
  ###
24
- # @param \stdClass $json_object
25
- # @param ModelFactoryInterface $factory
38
+ # This method is used for creating an instance of this class by a json_object.
39
+ #
40
+ # * *Args* :
41
+ # - +json_object+ -> the json_object received from the api
42
+ # - +factory+ -> instance of AboutYou::SDK::Factory::DefaultModelFactory
26
43
  #
27
- # @return static
44
+ # * *Returns* :
45
+ # - Instance of AboutYou::SDK::Model::ProductSearchResult
28
46
  ###
29
47
  def self.create_from_json(json_object, factory)
30
48
  product_search_result = new
@@ -51,6 +69,13 @@ module AboutYou
51
69
  product_search_result
52
70
  end
53
71
 
72
+ ###
73
+ # This method is used for parsing the facets of the search result
74
+ #
75
+ # * *Args* :
76
+ # - +json_object+ -> the json_object received from the api
77
+ # - +factory+ -> instance of AboutYou::SDK::Factory::DefaultModelFactory
78
+ ###
54
79
  def parse_facets(json_object, factory)
55
80
  self.categories = factory.create_categories_facets(
56
81
  json_object['categories']
@@ -66,9 +91,10 @@ module AboutYou
66
91
  end
67
92
 
68
93
  ###
69
- # Returns the min price in euro cent or null, if the price range was not requested/selected
94
+ # Getter for the min price
70
95
  #
71
- # * @return integer|null
96
+ # * *Returns* :
97
+ # - nil / Integer
72
98
  ###
73
99
  def min_price
74
100
  return nil if price_ranges.empty?
@@ -82,9 +108,10 @@ module AboutYou
82
108
  end
83
109
 
84
110
  ###
85
- # Returns the max price in euro cent, if the price range was not requested/selected
111
+ # Getter for the max price
86
112
  #
87
- # @return integer|null
113
+ # * *Returns* :
114
+ # - nil / Integer
88
115
  ###
89
116
  def max_price
90
117
  return nil if price_ranges.empty?
@@ -98,7 +125,10 @@ module AboutYou
98
125
  end
99
126
 
100
127
  ###
101
- # @return Category[]
128
+ # Getter for the category tree
129
+ #
130
+ # * *Returns* :
131
+ # - [] / Array containing instances of AboutYou::SDK::Model::Category
102
132
  ###
103
133
  def category_tree
104
134
  top_level_categories = []
@@ -2,21 +2,27 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # this class represents a products ean result model
7
- #
8
6
  ###
9
7
  class ProductsEansResult
8
+ # Array of not found eans
10
9
  attr_accessor :eans_not_found
10
+ # String page hash
11
11
  attr_accessor :page_hash
12
+ # Array of errors
12
13
  attr_accessor :errors
14
+ # Array of instances of AboutYou::SDK::Model::Product
13
15
  attr_accessor :products
14
16
 
15
17
  ###
16
- # @param \stdClass $json_object
17
- # @param ModelFactoryInterface $factory
18
+ # This method is used for creating an instance of this class by a json_object.
18
19
  #
19
- # @return static
20
+ # * *Args* :
21
+ # - +json_object+ -> the json_object received from the api
22
+ # - +factory+ -> instance of AboutYou::SDK::Factory::DefaultModelFactory
23
+ #
24
+ # * *Returns* :
25
+ # - Instance of AboutYou::SDK::Model::ProductsEansResult
20
26
  ###
21
27
  def self.create_from_json(json_object, factory)
22
28
  products_ean_result = new
@@ -2,23 +2,29 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents a products result model
7
- #
8
6
  ###
9
7
  class ProductsResult
10
8
  include AbstractModel
11
9
 
12
- attr_accessor :ids_not_found
10
+ # Array of not found product ids
11
+ attr_accessor :productsNotFound
12
+ # String page hash
13
13
  attr_accessor :page_hash
14
+ # Array of errors
14
15
  attr_accessor :errors
16
+ # Array of instances of AboutYou::SDK::Model::Product
15
17
  attr_accessor :products
16
18
 
17
19
  ###
18
- # @param \stdClass $json_object
19
- # @param ModelFactoryInterface $factory
20
+ # This method is used for creating an instance of this class by a json_object.
20
21
  #
21
- # @return static
22
+ # * *Args* :
23
+ # - +json_object+ -> the json_object received from the api
24
+ # - +factory+ -> instance of AboutYou::SDK::Factory::DefaultModelFactory
25
+ #
26
+ # * *Returns* :
27
+ # - Instance of AboutYou::SDK::Model::ProductsResult
22
28
  ###
23
29
  def self.create_from_json(json_object, factory)
24
30
  products_result = new
@@ -31,7 +37,7 @@ module AboutYou
31
37
  if json_object['ids']
32
38
  json_object['ids'].each do |key, json_product|
33
39
  if json_product['error_code']
34
- products_result.ids_not_found.push(key)
40
+ products_result.productsNotFound.push(key)
35
41
  products_result.errors.push(json_product)
36
42
  next
37
43
  end
@@ -43,13 +49,6 @@ module AboutYou
43
49
 
44
50
  products_result
45
51
  end
46
-
47
- ###
48
- # @return integer[] array of product ids
49
- ###
50
- def products_not_found
51
- ids_not_found
52
- end
53
52
  end
54
53
  end
55
54
  end
@@ -2,21 +2,37 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents an result error model
7
- #
8
6
  ###
9
7
  module ResultError
8
+ # error ident
10
9
  attr_accessor :error_ident
10
+ # error code
11
11
  attr_accessor :error_code
12
+ # error message
12
13
  attr_accessor :error_message
13
14
 
15
+ ###
16
+ # Constructor for the AboutYou::SDK::Model::ResultError class
17
+ #
18
+ # * *Args* :
19
+ # - +json_object+ -> the json_object received from the api
20
+ #
21
+ # * *Returns* :
22
+ # - an instance of AboutYou::SDK::Model::ResultError
23
+ ###
14
24
  def initialize(json_object)
15
25
  parse_error_result(json_object)
16
26
 
17
27
  self
18
28
  end
19
29
 
30
+ ###
31
+ # This method parses the error result
32
+ #
33
+ # * *Args* :
34
+ # - +json_object+ -> the json_object received from the api
35
+ ###
20
36
  def parse_error_result(json_object)
21
37
  self.error_ident = json_object.key?('error_ident') ? String(json_object['error_ident']) : nil
22
38
  self.error_code = json_object.key?('error_code') ? Integer(json_object['error_code']) : 0
@@ -2,42 +2,68 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents a variant model
7
- #
8
6
  ###
9
7
  class Variant
10
8
  include AbstractModel
11
-
9
+ # instance of AboutYou::SDK::Factory::DefaultModelFactory
12
10
  attr_accessor :factory
11
+ # instance of AboutYou::SDK::Model::Product
13
12
  attr_accessor :product
13
+ # Integer id
14
14
  attr_accessor :id
15
+ # Array of AboutYou::SDK::Model::Image
15
16
  attr_accessor :images
17
+ # instance of AboutYou::SDK::Model::Image
16
18
  attr_accessor :selected_image
19
+ # Integer about number id
17
20
  attr_accessor :about_number
21
+ # Array of AboutYou::SDK::Model::FacetGroup
18
22
  attr_accessor :facet_groups
23
+ # String ean
19
24
  attr_accessor :ean
25
+ # Boolean is variant default for product or not
20
26
  attr_accessor :is_default
27
+ # Integer price
21
28
  attr_accessor :price
29
+ # Integer old price
22
30
  attr_accessor :old_price
31
+ # Integer retail price
23
32
  attr_accessor :retail_price
33
+ # additional information
24
34
  attr_accessor :additional_info
35
+ # integer quantity
25
36
  attr_accessor :quantity
37
+ # Array of Integer facet_ids
26
38
  attr_accessor :facet_ids
39
+ # Integer first active data
27
40
  attr_accessor :first_active_date
41
+ # integer first Sale data
28
42
  attr_accessor :first_sale_date
43
+ # Integer creation date
29
44
  attr_accessor :created_date
45
+ # Integer update Date
30
46
  attr_accessor :updated_date
47
+ # String color
31
48
  attr_accessor :color
49
+ # Integer length
32
50
  attr_accessor :length
51
+ # string season_code
33
52
  attr_accessor :season_code
34
53
 
35
54
  ###
36
- # @param \stdClass $json_object
37
- # @param ModelFactoryInterface $factory
38
- # @param Product $product
55
+ # This method is used for creating an instance of this class by a json_object.
56
+ #
57
+ # * *Args* :
58
+ # - +json_object+ -> the json_object received from the api
59
+ # - +factory+ -> instance of AboutYou::SDK::Factory::DefaultModelFactory
60
+ # - +product+ -> Product of this variant
61
+ #
62
+ # * *Fails* :
63
+ # - if json_object has no id
39
64
  #
40
- # @return static
65
+ # * *Returns* :
66
+ # - Instance of AboutYou::SDK::Model::Variant
41
67
  ###
42
68
  def self.create_from_json(json_object, factory, product)
43
69
  fail 'MalformedJsonException' unless json_object['id']
@@ -73,6 +99,15 @@ module AboutYou
73
99
  variant
74
100
  end
75
101
 
102
+ ###
103
+ # This method is used for parsing images
104
+ #
105
+ # * *Args* :
106
+ # - +image_json+ -> the image json_object received from the api
107
+ #
108
+ # * *Returns* :
109
+ # - [] / Array of instances of AboutYou::SDK::Model::Image
110
+ ###
76
111
  def parse_images(image_json)
77
112
  image_array = []
78
113
  image_json.each do |image|
@@ -83,11 +118,13 @@ module AboutYou
83
118
  end
84
119
 
85
120
  ###
86
- # Get image by given hash.
121
+ # This method searches for an image by a certain hash
87
122
  #
88
- # @param string $hash The image hash.
123
+ # * *Args* :
124
+ # - +hash+ -> the hash used for searching
89
125
  #
90
- # @return Image
126
+ # * *Returns* :
127
+ # - nil / instance of AboutYou::SDK::Model::Image
91
128
  ###
92
129
  def image_by_hash(hash)
93
130
  images.each do |image|
@@ -98,13 +135,13 @@ module AboutYou
98
135
  end
99
136
 
100
137
  ###
101
- # Select a specific image.
138
+ # You can select an image with this method by a certain hash
102
139
  #
103
- # @param string $hash The image hash or null for default image.
140
+ # * *Args* :
141
+ # - +hash+ -> the hash used for selecting [optional]
104
142
  #
105
- # @return void
106
- #
107
- # @depracted
143
+ # * *Returns* :
144
+ # - Boolean determining whether the selection was successful or not
108
145
  ###
109
146
  def select_image(hash = nil)
110
147
  if hash
@@ -117,9 +154,10 @@ module AboutYou
117
154
  end
118
155
 
119
156
  ###
120
- # Get selected or default image.
157
+ # Getter for selected / default image
121
158
  #
122
- # @return Image
159
+ # * *Returns* :
160
+ # - nil / AboutYou::SDK::Model::Image
123
161
  ###
124
162
  def image
125
163
  if selected_image
@@ -131,6 +169,15 @@ module AboutYou
131
169
  nil
132
170
  end
133
171
 
172
+ ###
173
+ # This method parses the facet ids of a certain json_object
174
+ #
175
+ # * *Args* :
176
+ # - +json_object+ -> The json_object received from the api
177
+ #
178
+ # * *Returns* :
179
+ # - {} / Hash containing pairs of group_id => attribute_ids
180
+ ###
134
181
  def parse_facet_ids(json_object)
135
182
  ids = {}
136
183
 
@@ -142,33 +189,47 @@ module AboutYou
142
189
  ids
143
190
  end
144
191
 
192
+ ###
193
+ # This method generated a facet group set for a certain json_object
194
+ #
195
+ # * *Args* :
196
+ # - +json_object+ -> The json_object received from the api
197
+ ###
145
198
  def generate_facet_group_set(json_object)
146
199
  ids = parse_facet_ids(json_object)
147
200
  self.facet_groups = AboutYou::SDK::Model::FacetGroupSet.new(ids)
148
201
  end
149
202
 
150
203
  ###
151
- # @param integer $group_id
204
+ # This method searches by a certain facet group id
205
+ #
206
+ # * *Args* :
207
+ # - +group_id+ -> The group_id used for searching
152
208
  #
153
- # @return FacetGroup|null
209
+ # * *Returns* :
210
+ # - nil / instance of AboutYou::SDK::Model::FacetGroup
154
211
  ###
155
212
  def facet_group(group_id)
156
213
  facet_groups.group(group_id)
157
214
  end
158
215
 
159
216
  ###
160
- # @return FacetGroup|null
217
+ # Getter for the size facet group
218
+ #
219
+ # * *Returns* :
220
+ # - instance of AboutYou::SDK::Model::FacetGroup
161
221
  ###
162
222
  def size
163
- ###
164
223
  # @todo: Instance level caching
165
- ###
166
224
  group_id = size_group_id
167
225
  facet_group(group_id) unless group_id.empty?
168
226
  end
169
227
 
170
228
  ###
171
- # @return integer|null
229
+ # This method is used for getting the size group id
230
+ #
231
+ # * *Returns* :
232
+ # - nil / group_id
172
233
  ###
173
234
  def size_group_id
174
235
  keys = {}
@@ -192,10 +253,10 @@ module AboutYou
192
253
  end
193
254
 
194
255
  ###
195
- # Returns the quantity per pack for this variant.
196
- # By default, this returns 1. But some items can have a bigger number.
256
+ # Getter for the quantity per pack
197
257
  #
198
- # @return int quantity per pack
258
+ # * *Returns* :
259
+ # - Integer quantity
199
260
  ###
200
261
  def quantity_per_pack
201
262
  facet_group = facet_group(