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.
- checksums.yaml +8 -8
- data/lib/aboutyou-sdk.rb +0 -3
- data/lib/aboutyou-sdk/CacheProvider/Dalli.rb +58 -0
- data/lib/aboutyou-sdk/CacheProvider/Redis.rb +58 -0
- data/lib/aboutyou-sdk/Model/AbstractModel.rb +7 -18
- data/lib/aboutyou-sdk/Model/App.rb +38 -26
- data/lib/aboutyou-sdk/Model/Autocomplete.rb +74 -63
- data/lib/aboutyou-sdk/Model/Basket.rb +243 -237
- data/lib/aboutyou-sdk/Model/CategoryManager/DefaultCategoryManager.rb +13 -1
- data/lib/aboutyou-sdk/Model/FacetManager/DefaultFacetManager.rb +14 -2
- data/lib/aboutyou-sdk/Model/ProductSearchResult/FacetCount.rb +20 -13
- data/lib/aboutyou-sdk/Model/ProductSearchResult/FacetCounts.rb +39 -18
- data/lib/aboutyou-sdk/Model/ProductSearchResult/PriceRange.rb +30 -28
- data/lib/aboutyou-sdk/Model/ProductSearchResult/SaleCounts.rb +57 -44
- data/lib/aboutyou-sdk/Model/ProductSearchResult/TermsCount.rb +27 -18
- data/lib/aboutyou-sdk/Query.rb +1 -0
- data/tests/testSaleCounts.rb +5 -0
- metadata +3 -30
@@ -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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
|
16
|
-
|
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
|
-
|
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
|
-
|
16
|
-
|
17
|
-
self.productCountWithoutAnyFacet = productCountWithoutAnyFacet;
|
33
|
+
self.productCountTotal = productCountTotal
|
34
|
+
self.productCountWithOtherFacet = productCountWithOtherFacet
|
35
|
+
self.productCountWithoutAnyFacet = productCountWithoutAnyFacet
|
18
36
|
end
|
19
37
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
44
|
-
###
|
45
|
-
def parseTerms(jsonTerms)
|
52
|
+
saleCounts
|
53
|
+
end
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|