aboutyou-sdk 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjFiOTBiOTIxNjQxMTM1ZDdkMzQ4NTU5YzA3MDU5YmRiMGY2MGUzZg==
4
+ NWJkYTExNDNlM2QxNjIzZjdjNzdmYWRhYWI1YjBlZjc5ODFjZGMwYQ==
5
5
  data.tar.gz: !binary |-
6
- YmM2MjIwOTg0ZGY0MjViYmYxNDY4NmNhYzM0MWYwY2MzMjU1MjM0Ng==
6
+ OGYwNWE3ZTVmNWQ5NDY2ZDczNTkwMzgxY2ViOGJlYjI1MzUxMDk1NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzY1MDBiM2NkZWRmM2IzNzE0NTBkZTlkYzI2YjdlMGZhYjg1ZWFiODM3MjYw
10
- ODc2MDg3M2I1NTdkYzFiY2Q1MmU3NzdiNzI1NDE5NDJjZmE2OThmMjVkOThi
11
- OGZhODViMWEzM2I2YzU2ODdmMzQyZTZiOTZlMTEzYjQ3ZDBjOTY=
9
+ MmI2OGI0MWE5NTMyNzIyMmRkMDMyNTg5ZTIzODI1YjQ4MTJkNzU3NTFhMzMz
10
+ MDRiMzliNDdhYWQ1NGU5M2Q0NmNjYzlmZTFmMzgxZmI5NTc0N2Y5ODQzODgx
11
+ M2JjMjMwMWQyZjg5NTg0MjFmNDExNDc0YTFhNzVmZjM0M2E1MDg=
12
12
  data.tar.gz: !binary |-
13
- ZGM2MDFjNjAzZTU5MmI1ZDc2NzFlYTA4ZjFlMDliZTAxYmU2NzQ1ODZmNTdi
14
- NGRjODIwOGJjMjVjMDZhN2Y2ZmZlNzA2ZjkyMGE2NDRjNzRkMzUwOGE4MTI3
15
- MDMyYTM2MDI0MTEyMGQ3NTg2ZDdlYWQ0NjBhODkwY2EyN2NlZGU=
13
+ NzgyM2ExY2Q5NmRjMDNmYTY0ZWM0MzY4NDdhNDkyMmY3NzZhZmY4NTQ0YTcx
14
+ YzE1MmJkZWYxMjBiODAxNzA2ZDA2ODE3N2NiYTdjYTNlMjBlN2MxYjUxNjZl
15
+ MWQwZjY2MzIxZjM1MWRmMWNiYjk4NzczMGFhYWEyMDA2Njk2YzI=
@@ -636,6 +636,19 @@ module AboutYou
636
636
 
637
637
  flatten_categories
638
638
  end
639
+
640
+ ###
641
+ # this method creates the brand model
642
+ #
643
+ # * *Args* :
644
+ # - +json_object+ -> the response from the api in json format
645
+ #
646
+ # * *Returns* :
647
+ # - an instance of AboutYou::SDK::Model::Brand
648
+ ###
649
+ def create_brand(json_object)
650
+ AboutYou::SDK::Model::Brand.create_from_json(json_object)
651
+ end
639
652
 
640
653
  ###
641
654
  # this method tries to handle errors which are received from the api
@@ -13,25 +13,31 @@ module AboutYou
13
13
  TYPE_PRODUCTS = 'products'
14
14
  # argument for api when requiring categories
15
15
  TYPE_CATEGORIES = 'categories'
16
+ # argument for api when requiring brands
17
+ TYPE_BRANDS = 'brands'
16
18
 
17
19
  # the products of the autocomplete
18
20
  attr_accessor :products
19
21
  # the categories of the autocomplete
20
22
  attr_accessor :categories
23
+ # the brands of the autocomplete
24
+ attr_accessor :brands
21
25
 
22
26
  ###
23
27
  # the Constructor for the autocomplete class
24
28
  #
25
29
  # * *Args* :
26
- # - +product_count_total+ -> the total productcount
27
- # - +product_count_with_other_facet+ -> the productcount without any facets
30
+ # - +categories+ -> the products of the autocomplete
31
+ # - +products+ -> the categories of the autocomplete
32
+ # - +brands+ -> the brands of the autocomplete
28
33
  #
29
34
  # * *Returns* :
30
35
  # - Instance of AboutYou::SDK::Model::AutoComplete
31
36
  ###
32
- def initialize(categories = nil, products = nil)
37
+ def initialize(categories = nil, products = nil, brands = nil)
33
38
  self.categories = categories
34
39
  self.products = products
40
+ self.brands = brands
35
41
  end
36
42
 
37
43
  ###
@@ -47,7 +53,8 @@ module AboutYou
47
53
  def self.create_from_json(json_object, factory)
48
54
  new(
49
55
  parse_categories(json_object, factory),
50
- parse_products(json_object, factory)
56
+ parse_products(json_object, factory),
57
+ parse_brands(json_object, factory)
51
58
  )
52
59
  end
53
60
 
@@ -94,6 +101,28 @@ module AboutYou
94
101
 
95
102
  products
96
103
  end
104
+
105
+ ###
106
+ # This method parses the json object and builds product models from it
107
+ #
108
+ # * *Args* :
109
+ # - +json_object+ -> the json response from the api
110
+ # - +factory+ -> the model factory responsible for building the models
111
+ #
112
+ # * *Returns* :
113
+ # - Array containing instances of AboutYou::SDK::Model::Product
114
+ ###
115
+ def self.parse_brands(json_object, factory)
116
+ return NOT_REQUESTED unless json_object.key?('brands')
117
+ return [] if json_object['brands'].nil?
118
+
119
+ brands = []
120
+ json_object['brands'].each do |brand|
121
+ brands.push(factory.create_brand(brand))
122
+ end
123
+
124
+ brands
125
+ end
97
126
  end
98
127
  end
99
128
  end
@@ -0,0 +1,29 @@
1
+ module AboutYou
2
+ module SDK
3
+ module Model
4
+ ###
5
+ # This Class represents a brand model
6
+ #
7
+ # author:: Collins GmbH & Co KG
8
+ ###
9
+ class Brand
10
+ attr_accessor :id
11
+ attr_accessor :name
12
+
13
+ ###
14
+ # @param object $json_object
15
+ #
16
+ # @return Basket
17
+ ###
18
+ def self.create_from_json(json_object)
19
+ brand = new
20
+
21
+ brand.id = json_object['id']
22
+ brand.name = json_object['name']
23
+
24
+ brand
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -31,7 +31,7 @@ module AboutYou
31
31
  limit.is_a?(Integer) || limit[/\d/]
32
32
  options['limit'] = Integer(limit)
33
33
  end
34
-
34
+
35
35
  options['types'] = types unless types.empty?
36
36
 
37
37
  query.push(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aboutyou-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferenc Beutel
@@ -79,6 +79,7 @@ files:
79
79
  - lib/AboutYou/Model/app.rb
80
80
  - lib/AboutYou/Model/autocomplete.rb
81
81
  - lib/AboutYou/Model/basket.rb
82
+ - lib/AboutYou/Model/brand.rb
82
83
  - lib/AboutYou/Model/categories_result.rb
83
84
  - lib/AboutYou/Model/category.rb
84
85
  - lib/AboutYou/Model/category_tree.rb