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
@@ -3,17 +3,21 @@ module AboutYou
3
3
  module Model
4
4
  ###
5
5
  # This Class represents a brand model
6
- #
7
- # author:: Collins GmbH & Co KG
8
6
  ###
9
7
  class Brand
8
+ # the id of the brand
10
9
  attr_accessor :id
10
+ # the name of the brand
11
11
  attr_accessor :name
12
12
 
13
13
  ###
14
- # @param object $json_object
14
+ # This method is used for creating an instance of this class by a json_object.
15
15
  #
16
- # @return Basket
16
+ # * *Args* :
17
+ # - +json_object+ -> the json_object received from the api
18
+ #
19
+ # * *Returns* :
20
+ # - Instance of AboutYou::SDK::Model::Brand
17
21
  ###
18
22
  def self.create_from_json(json_object)
19
23
  brand = new
@@ -2,15 +2,26 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class is used as a model for a categories result
7
- #
8
6
  ###
9
7
  class CategoriesResult
8
+ # Array containing instances of AboutYou::SDK::Model::Category
10
9
  attr_accessor :categories
10
+ # Array containing the categories which are not found
11
11
  attr_accessor :categories_not_found
12
+ # the ids of the categories in this result
12
13
  attr_accessor :ids
13
14
 
15
+ ###
16
+ # Constructor for the AboutYou::SDK::Model::CategoriesResult class
17
+ #
18
+ # * *Args* :
19
+ # - +category_manager+ -> instance of AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager
20
+ # - +ids+ -> the ids of the categories in this result
21
+ #
22
+ # * *Returns* :
23
+ # - an instance of AboutYou::SDK::Model::CategoriesResult
24
+ ###
14
25
  def initialize(category_manager, ids)
15
26
  self.ids = ids
16
27
  self.categories = category_manager.categories(
@@ -2,43 +2,55 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents a category model
7
- #
8
6
  ###
9
7
  class Category
8
+ # all categories
10
9
  ALL = false
10
+ # only active categories
11
11
  ACTIVE_ONLY = true
12
12
 
13
- # @var integer */
13
+ # id of the category
14
14
  attr_accessor :id
15
- # @var string */
15
+ # name of the category
16
16
  attr_accessor :name
17
- # @var boolean */
17
+ # boolean determining whether the category is active
18
18
  attr_accessor :is_active
19
- # @var integer */
19
+ # position of the category
20
20
  attr_accessor :position
21
- # @var Category */
21
+ # id of the parent category
22
22
  attr_accessor :parent_id
23
- # @var Category[] */
23
+ # Array containing all subcategories
24
24
  attr_accessor :all_subcategories
25
- # @var Category[] */
25
+ # Array containing all active subcategories
26
26
  attr_accessor :active_subcategories
27
- # @var integer */
27
+ # count of products in category
28
28
  attr_accessor :product_count
29
+ # instance of AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager
29
30
  attr_accessor :category_manager
30
31
 
32
+ ###
33
+ # Constructor for the AboutYou::SDK::Model::Category class
34
+ #
35
+ # * *Returns* :
36
+ # - an instance of AboutYou::SDK::Model::Category
37
+ ###
31
38
  def initialize
32
39
  self.all_subcategories = []
33
40
  self.active_subcategories = []
41
+
42
+ self
34
43
  end
35
44
 
36
45
  ###
37
- # @param object $json_object json as object tree
38
- # @param ModelFactoryInterface $factory
39
- # @param Category|null $parent
46
+ # This method is used for creating an instance of this class by a json_object.
47
+ #
48
+ # * *Args* :
49
+ # - +json_object+ -> the json_object received from the api
50
+ # - +cat_manager+ -> instance of AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager
40
51
  #
41
- # @return static
52
+ # * *Returns* :
53
+ # - Instance of AboutYou::SDK::Model::Category
42
54
  ###
43
55
  def self.create_from_json(json_object, cat_manager)
44
56
  category = new
@@ -54,14 +66,21 @@ module AboutYou
54
66
  end
55
67
 
56
68
  ###
57
- # @return boolean
69
+ # This method checks if the complete category path up to this category is
70
+ # active
71
+ #
72
+ # * *Returns* :
73
+ # - Boolean determining whether the complete path up to this category is active or not
58
74
  ###
59
75
  def path_active?
60
76
  is_active && (parent.nil? || parent.path_active?)
61
77
  end
62
78
 
63
79
  ###
64
- # @return Category|null
80
+ # This method returns the parent category
81
+ #
82
+ # * *Returns* :
83
+ # - Either instance of AboutYou::SDK::Model::Category or nil if no parent category is set
65
84
  ###
66
85
  def parent
67
86
  return nil unless parent_id
@@ -70,9 +89,13 @@ module AboutYou
70
89
  end
71
90
 
72
91
  ###
73
- # @param bool $activeOnly
92
+ # This method is used for getting all subcategories
74
93
  #
75
- # @return Category[]
94
+ # * *Args* :
95
+ # - +active_only+ -> boolean controlling whether the result should only contain active categories or not
96
+ #
97
+ # * *Returns* :
98
+ # - Hash containing pairs of category_id => instance of AboutYou::SDK::Model::Category
76
99
  ###
77
100
  def subcategories(active_only = ACTIVE_ONLY)
78
101
  subcategories = category_manager.subcategories(id, active_only)
@@ -88,7 +111,10 @@ module AboutYou
88
111
  end
89
112
 
90
113
  ###
91
- # @return Category[]
114
+ # This method is used for getting the breadcrumb up to this category
115
+ #
116
+ # * *Returns* :
117
+ # - Array containing instances of AboutYou::SDK::Model::Category
92
118
  ###
93
119
  def breadcrumb
94
120
  breadcrumb = parent ? parent.breadcrumb : []
@@ -2,31 +2,45 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents a category tree model
7
- #
8
6
  ###
9
7
  class CategoryTree
10
- # @var CategoryManagerInterface */
8
+ # instance of AboutYou::SDK::Model::CategoryManager::DefaultCategoryManager
11
9
  attr_accessor :category_manager
12
10
 
11
+ ###
12
+ # Constructor for the AboutYou::SDK::Model::CategoryTree class
13
+ #
14
+ # * *Args* :
15
+ # - +cat_manager+ -> The category manager
16
+ #
17
+ # * *Returns* :
18
+ # - an instance of AboutYou::SDK::Model::CategoryTree
19
+ ###
13
20
  def initialize(cat_manager)
14
21
  self.category_manager = cat_manager
22
+
23
+ self
15
24
  end
16
25
 
17
26
  ###
18
- # @param bool $activeOnly if true, then only active categories will returned, otherwise all categories
27
+ # This method is used for getting the root categories of the tree
28
+ #
29
+ # * *Args* :
30
+ # - +act_only+ -> boolean controlling whether the result should only contain active categories or not
19
31
  #
20
- # @return array|Category[]
32
+ # * *Returns* :
33
+ # - a Hash containing pairs of category_id => instance of AboutYou::SDK::Model::Category
21
34
  ###
22
35
  def categories(act_only = AboutYou::SDK::Model::Category::ACTIVE_ONLY)
23
36
  category_manager.category_tree(act_only)
24
37
  end
25
38
 
26
39
  ###
27
- # Count active root all categories
40
+ # This method counts all active root categories
28
41
  #
29
- # {@inheritdoc}
42
+ # * *Returns* :
43
+ # - Integer count of active root categories
30
44
  ###
31
45
  def count
32
46
  categories(true).count
@@ -2,9 +2,7 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents a Facet model
7
- #
8
6
  ###
9
7
  class Facet
10
8
  # Group Id for Brands
@@ -53,28 +51,39 @@ module AboutYou
53
51
  FACET_QUANTITY_PER_PACK = 263
54
52
  # Group Id for Season Code
55
53
  FACET_SEASON_CODE = 289
56
-
54
+ # api-call name for requiring all facets
55
+ FACETS_ALL = '_all'
56
+ # api-call-value for requiring unlimited facets
57
+ FACETS_UNLIMITED = -1
58
+
59
+ # json_object with which this instance was created
57
60
  attr_accessor :json_object
58
- # @var integer */
61
+ # id of the facet
59
62
  attr_accessor :id
60
- # @var string */
63
+ # name of the facet
61
64
  attr_accessor :name
62
- # @var string */
65
+ # value of the facet
63
66
  attr_accessor :value
64
- # @var integer */
67
+ # id of the group of the facet
65
68
  attr_accessor :group_id
66
- # @var string */
69
+ # name of the group of the facet
67
70
  attr_accessor :group_name
68
- # @var array */
71
+ # options of the facet
69
72
  attr_accessor :options
70
73
 
71
74
  ###
72
- # @param integer $id
73
- # @param string $name
74
- # @param string $value
75
- # @param integer $group_id
76
- # @param string $group_name
77
- # @param array $options
75
+ # Constructor for the AboutYou::SDK::Model::Facet class
76
+ #
77
+ # * *Args* :
78
+ # - +id+ -> the id of the facet
79
+ # - +name+ -> the name of the facet
80
+ # - +value+ -> the value of the facet
81
+ # - +group_id+ -> id of the group of the facet
82
+ # - +group_name+ -> name of the group of the facet
83
+ # - +options+ -> options of the facet
84
+ #
85
+ # * *Returns* :
86
+ # - an instance of AboutYou::SDK::Model::Facet
78
87
  ###
79
88
  def initialize(id, name, value, group_id, group_name, options = nil)
80
89
  self.id = id
@@ -83,12 +92,18 @@ module AboutYou
83
92
  self.group_id = group_id
84
93
  self.group_name = group_name
85
94
  self.options = options
95
+
96
+ self
86
97
  end
87
98
 
88
99
  ###
89
- # @param $json_object
100
+ # This method is used for creating an instance of this class by a json_object.
101
+ #
102
+ # * *Args* :
103
+ # - +json_object+ -> the json_object received from the api
90
104
  #
91
- # @return static
105
+ # * *Returns* :
106
+ # - Instance of AboutYou::SDK::Model::Facet
92
107
  ###
93
108
  def self.create_from_json(json_object)
94
109
  new(
@@ -102,9 +117,14 @@ module AboutYou
102
117
  end
103
118
 
104
119
  ###
105
- # a facet is unique with the combination about id and group id
120
+ # This method is used for creating a unique key for a facet
121
+ #
122
+ # * *Args* :
123
+ # - +group_id+ -> id of the group of a facet
124
+ # - +facet_id+ -> id of a facet
106
125
  #
107
- # @return string
126
+ # * *Returns* :
127
+ # - a String containing a unique key for a facet
108
128
  ###
109
129
  def unique_key(group_id = nil, facet_id = nil)
110
130
  return String(group_id) + ':' + String(facet_id) unless
@@ -115,11 +135,13 @@ module AboutYou
115
135
  end
116
136
 
117
137
  ###
118
- # Get option value.
138
+ # Getter for options
119
139
  #
120
- # @param string $key The option key.
140
+ # * *Args* :
141
+ # - +key+ -> The key for which options should be returned
121
142
  #
122
- # @return mixed
143
+ # * *Returns* :
144
+ # - either null if no options are set or a String containing an option
123
145
  ###
124
146
  def option(key)
125
147
  return unless options
@@ -2,38 +2,51 @@ module AboutYou
2
2
  module SDK
3
3
  module Model
4
4
  ###
5
- #
6
5
  # This class represents a facet group model
7
- #
8
6
  ###
9
7
  class FacetGroup
10
- # @var Facet[] */
8
+ # Array of instances of AboutYou::SDK::Model::Facet
11
9
  attr_accessor :facets
12
- # @var integer */
10
+ # id of this facet group
13
11
  attr_accessor :id
14
- # @var string */
12
+ # name of the facet group
15
13
  attr_accessor :name
14
+ # id of the group of this facet group
16
15
  attr_accessor :group_id
17
16
 
18
17
  ###
19
- # @param integer $id
20
- # @param string $name
18
+ # Constructor for the AboutYou::SDK::Model::FacetGroup class
19
+ #
20
+ # * *Args* :
21
+ # - +id+ -> the id of the facet group
22
+ # - +name+ -> the name of the facet group
23
+ #
24
+ # * *Returns* :
25
+ # - an instance of AboutYou::SDK::Model::FacetGroup
21
26
  ###
22
27
  def initialize(id, name)
23
28
  self.id = id
24
29
  self.name = name
25
30
  self.facets = {}
31
+
32
+ self
26
33
  end
27
34
 
28
35
  ###
29
- # @param Facet $facet
36
+ # this method adds a facet to the facet group
37
+ #
38
+ # * *Args* :
39
+ # - +facet+ -> instance of AboutYou::SDK::Model::Facet which should be added
30
40
  ###
31
41
  def add_facet(facet)
32
42
  facets[facet.id] = facet
33
43
  end
34
44
 
35
45
  ###
36
- # @param Facet[] $facet
46
+ # this method adds facets to the facet group
47
+ #
48
+ # * *Args* :
49
+ # - +facets+ -> Array containing instances of AboutYou::SDK::Model::Facet which should be added
37
50
  ###
38
51
  def add_facets(facets)
39
52
  facets.each do |facet|
@@ -42,28 +55,33 @@ module AboutYou
42
55
  end
43
56
 
44
57
  ###
45
- # Returns all facet names separated with the given parameter
46
- # eg. for size with to size facets "36" and "37" -> "36/37"
47
- #
48
- # @param string $separator
58
+ # this method is used for getting all of the facet names of this facet group
49
59
  #
50
- # @return string
60
+ # * *Args* :
61
+ # - +separator+ -> String controlling how the facet names should be seperated
62
+ #
63
+ # * *Returns* :
64
+ # - Array of Strings
51
65
  ###
52
66
  def facet_names(separator = '/')
53
67
  names = []
54
68
  facets.each do |facet|
55
69
  names.push(facet.name)
56
70
  end
57
-
58
71
  names.join(separator)
72
+
73
+ names
59
74
  end
60
75
 
61
76
  ###
62
- # facet groups are equal, if the ids and all child ids are equal
77
+ # This method is used for checking whether a given facet group is equal
78
+ # to this facet group
63
79
  #
64
- # @param FacetGroup $facet_group
65
- #
66
- # @return boolean
80
+ # * *Args* :
81
+ # - +facet_group+ -> instance of AboutYou::SDK::Model::FacetGroup used for checking
82
+ #
83
+ # * *Returns* :
84
+ # -Boolean determining whether the facet groups are equal
67
85
  ###
68
86
  def equal?(facet_group)
69
87
  return false unless id == facet_group.id
@@ -72,9 +90,10 @@ module AboutYou
72
90
  end
73
91
 
74
92
  ###
75
- # @see equal?
93
+ # This method is used for creating a unique key for this facet group
76
94
  #
77
- # @return string
95
+ # * *Returns* :
96
+ # - a String containing a unique key for this facet group
78
97
  ###
79
98
  def unique_key
80
99
  facet_ids = facets.keys
@@ -83,10 +102,25 @@ module AboutYou
83
102
  String(id) + ':' + String(facet_ids.join(','))
84
103
  end
85
104
 
105
+ ###
106
+ # Gett for the ids
107
+ #
108
+ # * *Returns* :
109
+ # - Hash containing a pair of facet_group_id => Array of facet_ids
110
+ ###
86
111
  def ids
87
112
  { id => facets.keys }
88
113
  end
89
114
 
115
+ ###
116
+ # This method checks if this facet group contains a facet
117
+ #
118
+ # * *Args* :
119
+ # - +facet+ -> instance of AboutYou::SDK::Model::Facet
120
+ #
121
+ # * *Returns* :
122
+ # - Boolean determining whether this facet group contains the facet or not
123
+ ###
90
124
  def contains(facet)
91
125
  facets.key?(facet.id)
92
126
  end