aboutyou-sdk 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,13 +44,22 @@ module AboutYou
44
44
 
45
45
  ###
46
46
  # Gets the cached Categories for this app
47
+ #
48
+ # * *Returns* :
49
+ # - True/False determining whether the loading was sucessfull or not
47
50
  ###
48
51
  def loadCachedCategories
49
52
  parseJson(self.cache.get(self.cacheKey), self.shopApi.modelFactoryInstance) if self.cache && self.cache.exists(self.cacheKey)
50
53
  end
51
54
 
52
55
  ###
53
- # This method caches the currently read-in categories
56
+ # this method caches a given jsonObject
57
+ #
58
+ # * *Args* :
59
+ # - +jsonObject+ -> the jsonObject received from the api
60
+ #
61
+ # * *Returns* :
62
+ # - True/False determining whether the setting was sucessfull or not
54
63
  ###
55
64
  def cacheCategories(jsonObject)
56
65
  self.cache.set(self.cacheKey, jsonObject, DEFAULT_CACHE_DURATION)
@@ -58,6 +67,9 @@ module AboutYou
58
67
 
59
68
  ###
60
69
  # This method clears the cache
70
+ #
71
+ # * *Returns* :
72
+ # - True/False determining whether the clearing was sucessfull or not
61
73
  ###
62
74
  def clearCache
63
75
  self.cache.delete(self.cacheKey)
@@ -42,14 +42,23 @@ module AboutYou
42
42
  end
43
43
 
44
44
  ###
45
- # Gets the cached Facets for this app
45
+ # Gets the cached Categories for this app
46
+ #
47
+ # * *Returns* :
48
+ # - True/False determining whether the loading was sucessfull or not
46
49
  ###
47
50
  def loadCachedFacets
48
51
  parseJson(self.cache.get(self.cacheKey), self.shopApi.modelFactoryInstance) if self.cache && self.cache.exists(self.cacheKey)
49
52
  end
50
53
 
51
54
  ###
52
- # This method caches the currently read-in Facets
55
+ # this method caches a given jsonObject
56
+ #
57
+ # * *Args* :
58
+ # - +jsonObject+ -> the jsonObject received from the api
59
+ #
60
+ # * *Returns* :
61
+ # - True/False determining whether the setting was sucessfull or not
53
62
  ###
54
63
  def cacheFacets(jsonObject)
55
64
  self.cache.set(self.cacheKey, jsonObject, DEFAULT_CACHE_DURATION)
@@ -57,6 +66,9 @@ module AboutYou
57
66
 
58
67
  ###
59
68
  # This method clears the cache
69
+ #
70
+ # * *Returns* :
71
+ # - True/False determining whether the clearing was sucessfull or not
60
72
  ###
61
73
  def clearCache
62
74
  self.cache.delete(self.cacheKey)
@@ -1,24 +1,31 @@
1
1
  module AboutYou
2
2
  module SDK
3
3
  module Model
4
+
5
+ ###
6
+ # This class represents a FacetCount model.
7
+ #
8
+ # author:: Collins GmbH & Co KG
9
+ ###
4
10
  class FacetCount
5
-
6
- # @var Facet */
7
- @facet;
11
+ # The Facet
8
12
  attr_accessor :facet
9
-
10
- # @var integer */
11
- @count;
13
+ # The count of the facet
12
14
  attr_accessor :count
13
15
 
14
- ###
15
- # @param Facet $facet
16
- # @param integer $count
17
- ###
16
+ ###
17
+ # the Constructor for the facetcount class
18
+ #
19
+ # * *Args* :
20
+ # - +facet+ -> a facet
21
+ # - +count+ -> the count of the facet
22
+ #
23
+ # * *Returns* :
24
+ # - Instance of AboutYou::SDK::Model::FacetCount
25
+ ###
18
26
  def initialize(facet, count)
19
-
20
- self.facet = facet;
21
- self.count = count;
27
+ self.facet = facet
28
+ self.count = count
22
29
  end
23
30
  end
24
31
  end
@@ -1,36 +1,57 @@
1
1
  module AboutYou
2
2
  module SDK
3
3
  module Model
4
+ ###
5
+ # This class represents a FacetCounts model.
6
+ #
7
+ # author:: Collins GmbH & Co KG
8
+ ###
4
9
  class FacetCounts
5
-
10
+ # The groupId of the facetcounts
6
11
  attr_accessor :groupId
12
+ # an array of facetcount objects
7
13
  attr_accessor :facetCountList
14
+ # the cont of the products
8
15
  attr_accessor :productCountTotal
16
+ # the count of the products without facets
9
17
  attr_accessor :productCountWithoutAnyFacet
18
+ # the count of the procuts with other facets
10
19
  attr_accessor :productCountWithOtherFacet
11
20
 
12
-
21
+ ###
22
+ # the Constructor for the facetcounts class
23
+ #
24
+ # * *Args* :
25
+ # - +productCountTotal+ -> the total productcount
26
+ # - +productCountWithOtherFacet+ -> the productcount without any facets
27
+ # - +productCountWithoutAnyFacet+ -> the productcount with other facets
28
+ #
29
+ # * *Returns* :
30
+ # - Instance of AboutYou::SDK::Model::FacetCounts
31
+ ###
13
32
  def initialize(productCountTotal, productCountWithOtherFacet, productCountWithoutAnyFacet)
14
-
15
- self.productCountTotal = productCountTotal;
16
- self.productCountWithOtherFacet = productCountWithOtherFacet;
17
- self.productCountWithoutAnyFacet = productCountWithoutAnyFacet;
33
+ self.productCountTotal = productCountTotal
34
+ self.productCountWithOtherFacet = productCountWithOtherFacet
35
+ self.productCountWithoutAnyFacet = productCountWithoutAnyFacet
18
36
  end
19
37
 
20
- ###
21
- # @param integer $groupId
22
- # @param \stdClass $jsonObject
23
- # @param FacetCount[] $facetCounts
24
- #
25
- # @return FacetCounts
26
- ###
38
+ ###
39
+ # This method is used for creating an instance of this class by a jsonObject.
40
+ #
41
+ # * *Args* :
42
+ # - +groupId+ -> the groupId of the facetcounts
43
+ # - +jsonObject+ -> the jsonObject received from the api
44
+ # - +facetCountList+ -> a list of facetcount objects
45
+ #
46
+ # * *Returns* :
47
+ # - Instance of AboutYou::SDK::Model::FacetCounts
48
+ ###
27
49
  def self.createFromJson(groupId, jsonObject, facetCountList)
50
+ facetCounts = self.new(jsonObject["total"], jsonObject["other"], jsonObject["missing"])
51
+ facetCounts.groupId = groupId
52
+ facetCounts.facetCountList = facetCountList
28
53
 
29
- facetCounts = self.new(jsonObject["total"], jsonObject["other"], jsonObject["missing"])
30
- facetCounts.groupId = groupId;
31
- facetCounts.facetCountList = facetCountList;
32
-
33
- return facetCounts;
54
+ facetCounts
34
55
  end
35
56
  end
36
57
  end
@@ -1,47 +1,49 @@
1
1
  module AboutYou
2
2
  module SDK
3
3
  module Model
4
+ ###
5
+ # This class represents a Price Range model.
6
+ #
7
+ # author:: Collins GmbH & Co KG
8
+ ###
4
9
  class PriceRange
5
-
10
+ # the product count
6
11
  attr_accessor :productCount
12
+ # startpoint of the price range
7
13
  attr_accessor :from
14
+ # end of the price range
8
15
  attr_accessor :to
16
+ # min value of the price range
9
17
  attr_accessor :min
18
+ # max value of the price range
10
19
  attr_accessor :max
20
+ #
11
21
  attr_accessor :mean
22
+ #
12
23
  attr_accessor :sum
13
24
 
14
25
 
15
- ###
16
- # Expected json format
17
- # {
18
- # "count": 25138,
19
- # "from": 0,
20
- # "min": 399,
21
- # "max": 19999,
22
- # "to": 20000,
23
- # "total_count": 25138,
24
- # "total": 133930606,
25
- # "mean": 5327.8147028403
26
- # }
27
- #
28
- # @param \stdClass $jsonObject
29
- #
30
- # @return static
31
- ###
26
+ ###
27
+ # This method is used for creating an instance of this class by a jsonObject.
28
+ #
29
+ # * *Args* :
30
+ # - +jsonObject+ -> the jsonObject received from the api
31
+ #
32
+ # * *Returns* :
33
+ # - Instance of AboutYou::SDK::Model::PriceRange
34
+ ###
32
35
  def self.createFromJson(jsonObject)
36
+ priceRange = self.new
33
37
 
34
- priceRange = self.new
35
-
36
- priceRange.productCount = jsonObject["count"]
37
- priceRange.from = jsonObject["from"]
38
- priceRange.to = jsonObject["to"]
39
- priceRange.min = jsonObject["min"]
40
- priceRange.max = jsonObject["max"]
41
- priceRange.mean = jsonObject["mean"]
42
- priceRange.sum = jsonObject["total"]
38
+ priceRange.productCount = jsonObject["count"]
39
+ priceRange.from = jsonObject["from"]
40
+ priceRange.to = jsonObject["to"]
41
+ priceRange.min = jsonObject["min"]
42
+ priceRange.max = jsonObject["max"]
43
+ priceRange.mean = jsonObject["mean"]
44
+ priceRange.sum = jsonObject["total"]
43
45
 
44
- return priceRange;
46
+ priceRange
45
47
  end
46
48
  end
47
49
  end
@@ -1,57 +1,70 @@
1
1
  module AboutYou
2
2
  module SDK
3
3
  module Model
4
+ ###
5
+ # This class represents a Sale Counts model.
6
+ #
7
+ # author:: Collins GmbH & Co KG
8
+ ###
4
9
  class SaleCounts
5
10
 
6
- # @var integer */
7
- @productCountInSale;
8
- attr_accessor :productCountInSale
11
+ # count of products in sale
12
+ attr_accessor :productCountInSale
13
+ # count of prodocuts not in sale
14
+ attr_accessor :productCountNotInSale
15
+ # count of total products
16
+ attr_accessor :productCountTotal
17
+ # count of products without facet
18
+ attr_accessor :productCountWithoutAnyFacet
19
+ # count of products with other facets
20
+ attr_accessor :productCountWithOtherFacet
9
21
 
10
- # @var integer */
11
- @productCountNotInSale;
12
- attr_accessor :productCountNotInSale
13
-
14
- @productCountTotal
15
- attr_accessor :productCountTotal
16
-
17
- @productCountWithoutAnyFacet
18
- attr_accessor :productCountWithoutAnyFacet
19
-
20
- @productCountWithOtherFacet
21
- attr_accessor :productCountWithOtherFacet
22
-
23
- def initialize(productCountTotal, productCountWithOtherFacet, productCountWithoutAnyFacet)
24
-
25
- self.productCountTotal = productCountTotal;
26
- self.productCountWithOtherFacet = productCountWithOtherFacet;
27
- self.productCountWithoutAnyFacet = productCountWithoutAnyFacet;
28
- end
22
+ ###
23
+ # the Constructor for the sale counts class
24
+ #
25
+ # * *Args* :
26
+ # - +productCountTotal+ -> the total productcount
27
+ # - +productCountWithOtherFacet+ -> the productcount without any facets
28
+ # - +productCountWithoutAnyFacet+ -> the productcount with other facets
29
+ #
30
+ # * *Returns* :
31
+ # - Instance of AboutYou::SDK::Model::SaleCounts
32
+ ###
33
+ def initialize(productCountTotal, productCountWithOtherFacet, productCountWithoutAnyFacet)
34
+ self.productCountTotal = productCountTotal
35
+ self.productCountWithOtherFacet = productCountWithOtherFacet
36
+ self.productCountWithoutAnyFacet = productCountWithoutAnyFacet
37
+ end
29
38
 
30
- ###
31
- # @param \stdClass $jsonObject
32
- #
33
- # @return static
34
- ###
35
- def self.createFromJson(jsonObject)
36
- saleCounts = self.new(jsonObject["total"], jsonObject["other"], jsonObject["missing"]);
37
- saleCounts.parseTerms(jsonObject["terms"]);
38
-
39
- saleCounts
40
- end
39
+ ###
40
+ # This method is used for creating an instance of this class by a jsonObject.
41
+ #
42
+ # * *Args* :
43
+ # - +jsonObject+ -> the jsonObject received from the api
44
+ #
45
+ # * *Returns* :
46
+ # - Instance of AboutYou::SDK::Model::SaleCounts
47
+ ###
48
+ def self.createFromJson(jsonObject)
49
+ saleCounts = self.new(jsonObject["total"], jsonObject["other"], jsonObject["missing"])
50
+ saleCounts.parseTerms(jsonObject["terms"])
41
51
 
42
- ###
43
- # {@inheritdoc}
44
- ###
45
- def parseTerms(jsonTerms)
52
+ saleCounts
53
+ end
46
54
 
47
- jsonTerms.each do |term|
48
- if (term["term"] == "0")
49
- self.productCountNotInSale = term["count"];
50
- else
51
- self.productCountInSale = term["count"];
52
- end
53
- end
55
+ ###
56
+ # This method is used for parsing the terms of the jsonObject
57
+ #
58
+ # * *Args* :
59
+ # - +jsonTerms+ -> the terms of the jsonObject received from the api
60
+ ###
61
+ def parseTerms(jsonTerms)
62
+ jsonTerms.each do |term|
63
+ term["term"] == 0 ?
64
+ self.productCountNotInSale = term["count"] :
65
+ self.productCountInSale = term["count"]
54
66
  end
67
+ end
55
68
  end
56
69
  end
57
70
  end
@@ -1,26 +1,35 @@
1
1
  module AboutYou
2
2
  module SDK
3
3
  module Model
4
+ ###
5
+ # This class represents a Terms Count model.
6
+ #
7
+ # author:: Collins GmbH & Co KG
8
+ ###
4
9
  class TermsCounts
10
+ # count of total products
11
+ attr_accessor :productCountTotal
12
+ # count of products without facet
13
+ attr_accessor :productCountWithOtherFacet
14
+ # count of products with other facets
15
+ attr_accessor :productCountWithoutAnyFacet
5
16
 
6
- # @var integer */
7
- @productCountTotal;
8
- attr_accessor :productCountTotal
9
-
10
- # @var integer */
11
- @productCountWithOtherFacet;
12
- attr_accessor :productCountWithOtherFacet
13
-
14
- # @var integer */
15
- @productCountWithoutAnyFacet;
16
- attr_accessor :productCountWithoutAnyFacet
17
-
18
- def initialize(productCountTotal, productCountWithOtherFacet, productCountWithoutAnyFacet)
19
-
20
- self.productCountTotal = productCountTotal;
21
- self.productCountWithOtherFacet = productCountWithOtherFacet;
22
- self.productCountWithoutAnyFacet = productCountWithoutAnyFacet;
23
- end
17
+ ###
18
+ # the Constructor for the terms count class
19
+ #
20
+ # * *Args* :
21
+ # - +productCountTotal+ -> the total productcount
22
+ # - +productCountWithOtherFacet+ -> the productcount without any facets
23
+ # - +productCountWithoutAnyFacet+ -> the productcount with other facets
24
+ #
25
+ # * *Returns* :
26
+ # - Instance of AboutYou::SDK::Model::TermsCount
27
+ ###
28
+ def initialize(productCountTotal, productCountWithOtherFacet, productCountWithoutAnyFacet)
29
+ self.productCountTotal = productCountTotal
30
+ self.productCountWithOtherFacet = productCountWithOtherFacet
31
+ self.productCountWithoutAnyFacet = productCountWithoutAnyFacet
32
+ end
24
33
  end
25
34
  end
26
35
  end
@@ -250,6 +250,7 @@ module AboutYou
250
250
  if self.query.empty? && self.ghostQuery.empty?
251
251
  return []
252
252
  end
253
+ binding.pry
253
254
  parseResult(self.client.request(queryString), self.query.count > 1)
254
255
  end
255
256