aboutyou-sdk 0.0.29 → 0.0.30

Sign up to get free protection for your applications and to get access to all the features.
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,26 +2,28 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents a facet group set model
7
- #
8
6
  ###
9
7
  class FacetGroupSet
10
- # @var array */
8
+ # Array of ids of the facet groups in this set
11
9
  attr_accessor :ids
12
- # @var FacetGroup[] */
10
+ # Array of instances of AboutYou::SDK::Model::FacetGroups
13
11
  attr_accessor :groups
14
- # @var Facet[] */
12
+ # Array of instances of AboutYou::SDK::Model::Facet
15
13
  attr_accessor :facets
16
- # @var FacetManagerInterface */
17
14
  class << self
15
+ # instance of AboutYou::SDK::Model::Facet_Manager::DefaultFacetManager
18
16
  attr_accessor :facet_manager
19
17
  end
20
18
 
21
19
  ###
22
- # @param array $ids two dimensional array of group ids and array ids
20
+ # Constructor for the AboutYou::SDK::Model::FacetGroupSet class
23
21
  #
24
- # @throws \InvalidArgumentException
22
+ # * *Args* :
23
+ # - +ids+ -> the ids of the facet groups of this set
24
+ #
25
+ # * *Returns* :
26
+ # - an instance of AboutYou::SDK::Model::FacetGroupSet
25
27
  ###
26
28
  def initialize(ids)
27
29
  self.facets = {}
@@ -30,17 +32,27 @@ module AboutYou
30
32
  fail '\InvalidArgumentException! ids must be an associative array
31
33
  of [$groupId => [$facetId,...],..]' unless facet_ids.is_a?(Array)
32
34
  end
33
-
34
35
  self.ids = ids
36
+
37
+ self
35
38
  end
36
39
 
37
40
  ###
38
- # @return boolean
41
+ # This method checks whether this set is empty
42
+ #
43
+ # * *Returns* :
44
+ # - Boolean determining whether this set is empty or not
39
45
  ###
40
46
  def empty?
41
47
  ids.empty?
42
48
  end
43
49
 
50
+ ###
51
+ # This method is used for generating facet groups for this set
52
+ #
53
+ # * *Returns* :
54
+ # - Hash containing pairs of group_id => instance of AboutYou::SDK::Model::FacetGroup
55
+ ###
44
56
  def gen_lazy_groups
45
57
  groups = {}
46
58
  ids.each do |group_id, facet_ids|
@@ -61,11 +73,23 @@ module AboutYou
61
73
  groups
62
74
  end
63
75
 
76
+ ###
77
+ # Getter for the facet groups of this set
78
+ #
79
+ # * *Returns* :
80
+ # - Hash containing pairs of group_id => instance of AboutYou::SDK::Model::FacetGroup
81
+ ###
64
82
  def lazy_groups
65
83
  return @groups unless @groups.empty?
66
84
  gen_lazy_groups
67
85
  end
68
86
 
87
+ ###
88
+ # This method fetches the facets of this set
89
+ #
90
+ # * *Returns* :
91
+ # - Hash containing pairs of group_id => instance of AboutYou::SDK::Model::FacetGroup
92
+ ###
69
93
  def fetch
70
94
  return unless facets && facets.empty?
71
95
 
@@ -87,7 +111,10 @@ module AboutYou
87
111
  end
88
112
 
89
113
  ###
90
- # @return FacetGroup[]
114
+ # Getter for the facet groups of this set
115
+ #
116
+ # * *Returns* :
117
+ # - Hash containing pairs of group_id => instance of AboutYou::SDK::Model::FacetGroup
91
118
  ###
92
119
  def groups
93
120
  fetch if @groups.empty?
@@ -96,33 +123,55 @@ module AboutYou
96
123
  end
97
124
 
98
125
  ###
99
- # @param $group_id
126
+ # this method is used for getting a group of this set by a group id
100
127
  #
101
- # @return FacetGroup|null
128
+ # * *Returns* :
129
+ # - +group_id+ -> the group id for which the facet group should be returned
130
+ #
131
+ # * *Returns* :
132
+ # - Either nil if not found or instance of AboutYou::SDK::Model::FacetGroup
102
133
  ###
103
134
  def group(group_id)
104
135
  return groups[group_id] if groups[group_id]
105
136
  end
106
137
 
107
138
  ###
108
- # @param $group_id
139
+ # this method is used for checking whether a group is in this set or not
140
+ #
141
+ # * *Returns* :
142
+ # - +group_id+ -> the group id used for searching
109
143
  #
110
- # @return bool
144
+ # * *Returns* :
145
+ # - Boolean determining whether this set includes the group_id or not
111
146
  ###
112
147
  def group?(group_id)
113
148
  !ids[group_id].empty?
114
149
  end
115
150
 
116
151
  ###
117
- # @param string $key
152
+ # This method gets a facet by key
118
153
  #
119
- # @return Facet|null
154
+ # * *Returns* :
155
+ # - +key+ -> the facet key used for searching
156
+ #
157
+ # * *Returns* :
158
+ # - Either nil if not found or instance of AboutYou::SDK::Model::Facet
120
159
  ###
121
160
  def facet_by_key(key)
122
161
  fetch
123
162
  facets[key] ? facets[key] : nil
124
163
  end
125
164
 
165
+ ###
166
+ # This method gets a facet by given facet if and facet group id
167
+ #
168
+ # * *Returns* :
169
+ # - +facet_group_id+ -> the facet group id used for searching
170
+ # - +facet_id+ -> the facet id used for searching
171
+ #
172
+ # * *Returns* :
173
+ # - Either nil if not found or instance of AboutYou::SDK::Model::Facet
174
+ ###
126
175
  def facet(facet_group_id, facet_id)
127
176
  fetch if facets.empty?
128
177
 
@@ -131,10 +180,10 @@ module AboutYou
131
180
  end
132
181
 
133
182
  ###
134
- # set are equal, if all groups are equal
135
- # which means, that all included facet ids per group must be the same
183
+ # This method is used for creating a unique key for this facet group set
136
184
  #
137
- # @return string
185
+ # * *Returns* :
186
+ # - a String containing a unique key for this facet group set
138
187
  ###
139
188
  def unique_key
140
189
  ids.sort!
@@ -144,9 +193,13 @@ module AboutYou
144
193
  end
145
194
 
146
195
  ###
147
- # @param FacetUniqueKeyInterface $facetCompable
196
+ # This method checks whether this set contains a facet or facet group set
148
197
  #
149
- # @return boolean
198
+ # * *Args* :
199
+ # - +facet_compable+ -> Facet compable
200
+ #
201
+ # * *Returns* :
202
+ # - Either nil if wrong input or Boolean determining whether the compable is found or not
150
203
  ###
151
204
  def contains(facet_compable)
152
205
  return contains_facet_group_set(facet_compable) if
@@ -158,6 +211,15 @@ module AboutYou
158
211
  false
159
212
  end
160
213
 
214
+ ###
215
+ # This method checks whether a facet is in this set or not
216
+ #
217
+ # * *Args* :
218
+ # - +facet+ -> Facet compable
219
+ #
220
+ # * *Returns* :
221
+ # - Boolean determining whether this set includes the facet or not
222
+ ###
161
223
  def contains_facet_get_group_interface(facet)
162
224
  lazy_groups = self.lazy_groups
163
225
  id = facet.group_id
@@ -169,6 +231,15 @@ module AboutYou
169
231
  false
170
232
  end
171
233
 
234
+ ###
235
+ # This method checks whether a facet group set is in this set or not
236
+ #
237
+ # * *Args* :
238
+ # - +facet_group_set+ -> Facet compable
239
+ #
240
+ # * *Returns* :
241
+ # - Boolean determining whether this set includes the facet group set or not
242
+ ###
172
243
  def contains_facet_group_set(facet_group_set)
173
244
  return true if unique_key == facet_group_set.unique_key
174
245
 
@@ -180,6 +251,15 @@ module AboutYou
180
251
  true
181
252
  end
182
253
 
254
+ ###
255
+ # This method merges facet ids in an multi dimensional Array
256
+ #
257
+ # * *Args* :
258
+ # - +facet_ids_array+ -> Multi-Dimensional-Array containing facet ids
259
+ #
260
+ # * *Returns* :
261
+ # - Array of facet ids
262
+ ###
183
263
  def self.merge_facet_ids(facet_ids_array)
184
264
  ids = {}
185
265
 
@@ -198,7 +278,10 @@ module AboutYou
198
278
  end
199
279
 
200
280
  ###
201
- # @return array
281
+ # getter for the facet group ids
282
+ #
283
+ # * *Returns* :
284
+ # - Array of facet group ids
202
285
  ###
203
286
  def group_ids
204
287
  ids.keys
@@ -2,58 +2,65 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class is a represenatation of an Image model
7
- #
8
6
  ###
9
7
  class Image
8
+ # min width of an image
10
9
  MIN_WIDTH = 50
10
+ # min height of an image
11
11
  MIN_HEIGHT = 50
12
+ # max width of an image
12
13
  MAX_WIDTH = 1400
14
+ # max height of an image
13
15
  MAX_HEIGHT = 2000
14
16
 
15
17
  class << self
16
- attr_accessor :base_url
18
+ # base image url
19
+ attr_accessor :base_url
17
20
  end
18
- # @var null|string[] */
21
+ # Array of additional items
19
22
  attr_accessor :additional_items
20
- # @var null|string */
23
+ # Integer angle of the image
21
24
  attr_accessor :angle
22
- # @var null|string */
25
+ # String background color of image
23
26
  attr_accessor :background
24
- # @var null|string[] */
27
+ # String color of image
25
28
  attr_accessor :color
26
- # @var null|string */
29
+ # ext
27
30
  attr_accessor :ext
28
- # @var null|string */
31
+ # String gender of the image
29
32
  attr_accessor :gender
30
- # @var string */
33
+ # String hash of the image
31
34
  attr_accessor :hash
32
- # @var ImageSize */
35
+ # instance of AboutYou::SDK::Model::ImageSize
33
36
  attr_accessor :image_size
34
- # @var integer */
37
+ # Integer file size
35
38
  attr_accessor :file_size
36
- # @var null|string */
39
+ # String focus of the image
37
40
  attr_accessor :focus
38
- # @var string */
41
+ # Integer mime type of the image
39
42
  attr_accessor :mime_type
40
- # @var null|\stdClass */
43
+ # Hash model data
41
44
  attr_accessor :model_data
42
- # @var null|integer */
45
+ # Integer next detail level
43
46
  attr_accessor :next_detail_level
44
- # @var null|string */
47
+ # String preparation
45
48
  attr_accessor :preparation
46
- # @var null|array */
49
+ # Array of String tags
47
50
  attr_accessor :tags
48
- # @var null|string */
51
+ # Integer type
49
52
  attr_accessor :type
50
- # @var string */
53
+ # String View
51
54
  attr_accessor :view
52
55
 
53
56
  ###
54
- # @param \stdClass $json_object
57
+ # This method is used for creating an instance of this class by a json_object.
55
58
  #
56
- # @return static
59
+ # * *Args* :
60
+ # - +json_object+ -> the json_object received from the api
61
+ #
62
+ # * *Returns* :
63
+ # - Instance of AboutYou::SDK::Model::Image
57
64
  ###
58
65
  def self.create_from_json(json_object)
59
66
  image = new
@@ -84,10 +91,14 @@ module AboutYou
84
91
  end
85
92
 
86
93
  ###
87
- # @param int $width
88
- # @param int $height
94
+ # This method is used for getting the image url for image
95
+ #
96
+ # * *Args* :
97
+ # - +width+ -> Width of the image
98
+ # - +height+ -> Height of the image
89
99
  #
90
- # @return string returns the relative url
100
+ # * *Returns* :
101
+ # - String url for the image
91
102
  ###
92
103
  def url(width = 200, height = 200)
93
104
  width = [[width, MAX_WIDTH].min, MIN_WIDTH].max
@@ -2,17 +2,20 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents the image size of an image
7
- #
8
6
  ###
9
7
  class ImageSize
10
- # @var integer */
8
+ # Integer width
11
9
  attr_accessor :width
12
-
13
- # @var integer */
10
+ # Integer height
14
11
  attr_accessor :height
15
12
 
13
+ ###
14
+ # Constructor for the AboutYou::SDK::Model::ImageSize class
15
+ #
16
+ # * *Returns* :
17
+ # - an instance of AboutYou::SDK::Model::ImageSize
18
+ ###
16
19
  def initialize(width, height)
17
20
  self.width = width
18
21
  self.height = height
@@ -2,21 +2,30 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents an initiate order model
7
- #
8
6
  ###
9
7
  class InitiateOrder
8
+ # url of the order
10
9
  attr_accessor :url
10
+ # user token for the order
11
11
  attr_accessor :user_token
12
+ # app token of the order
12
13
  attr_accessor :app_token
14
+ # error code of the order
13
15
  attr_accessor :error_code
16
+ # error message of the order
14
17
  attr_accessor :error_message
15
18
 
16
19
  ###
17
- # @param string $url
18
- # @param string $user_token
19
- # @param string $app_token
20
+ # Constructor for the AboutYou::SDK::Model::InitiateOrder class
21
+ #
22
+ # * *Args* :
23
+ # - +url+ -> url of the order
24
+ # - +user_token+ -> user token for the order
25
+ # - +app_token+ -> app token of the order
26
+ #
27
+ # * *Returns* :
28
+ # - an instance of AboutYou::SDK::Model::InitiateOrder
20
29
  ###
21
30
  def initialize(url, user_token, app_token)
22
31
  self.url = url
@@ -27,9 +36,13 @@ module AboutYou
27
36
  end
28
37
 
29
38
  ###
30
- # @param \stdClass $json
39
+ # This method is used for creating an instance of this class by a json_object.
40
+ #
41
+ # * *Args* :
42
+ # - +json_object+ -> the json_object received from the api
31
43
  #
32
- # @return static
44
+ # * *Returns* :
45
+ # - Instance of AboutYou::SDK::Model::InitateOrder
33
46
  ###
34
47
  def self.create_from_json(json_object)
35
48
  order = new(
@@ -43,6 +56,12 @@ module AboutYou
43
56
  order
44
57
  end
45
58
 
59
+ ###
60
+ # This method is used for parsing the error result
61
+ #
62
+ # * *Args* :
63
+ # - +json_object+ -> the json_object received from the api
64
+ ###
46
65
  def parse_error_result(json_object)
47
66
  self.error_code = json_object.key?('error_code') ? json_object['error_code'] : 0
48
67
  self.error_message = json_object.key?('error_message') ? json_object['error_message'] : nil
@@ -2,14 +2,24 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents an order model
7
- #
8
6
  ###
9
7
  class Order
8
+ # id of the order
10
9
  attr_accessor :id
10
+ # basket of the order
11
11
  attr_accessor :basket
12
12
 
13
+ ###
14
+ # Constructor for the AboutYou::SDK::Model::InitiateOrder class
15
+ #
16
+ # * *Args* :
17
+ # - +id+ -> id of the order
18
+ # - +basket+ -> basket of the order
19
+ #
20
+ # * *Returns* :
21
+ # - an instance of AboutYou::SDK::Model::Order
22
+ ###
13
23
  def initialize(id, basket)
14
24
  self.id = id
15
25
  self.basket = basket