aboutyou-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/lib/aboutyou-sdk.rb +545 -0
- data/lib/aboutyou-sdk/Client.rb +125 -0
- data/lib/aboutyou-sdk/Constants.rb +48 -0
- data/lib/aboutyou-sdk/Criteria/ProductFields.rb +54 -0
- data/lib/aboutyou-sdk/Criteria/ProductSearchCriteria.rb +436 -0
- data/lib/aboutyou-sdk/Factory/DefaultModelFactory.rb +454 -0
- data/lib/aboutyou-sdk/Model/AbstractModel.rb +26 -0
- data/lib/aboutyou-sdk/Model/App.rb +35 -0
- data/lib/aboutyou-sdk/Model/Autocomplete.rb +92 -0
- data/lib/aboutyou-sdk/Model/Basket.rb +262 -0
- data/lib/aboutyou-sdk/Model/Basket/AbstractBasketItem.rb +76 -0
- data/lib/aboutyou-sdk/Model/Basket/BasketItem.rb +100 -0
- data/lib/aboutyou-sdk/Model/Basket/BasketSet.rb +192 -0
- data/lib/aboutyou-sdk/Model/Basket/BasketSetItem.rb +46 -0
- data/lib/aboutyou-sdk/Model/Basket/BasketVariantItem.rb +137 -0
- data/lib/aboutyou-sdk/Model/CategoriesResult.rb +15 -0
- data/lib/aboutyou-sdk/Model/Category.rb +126 -0
- data/lib/aboutyou-sdk/Model/CategoryManager/DefaultCategoryManager.rb +172 -0
- data/lib/aboutyou-sdk/Model/CategoryTree.rb +35 -0
- data/lib/aboutyou-sdk/Model/Facet.rb +105 -0
- data/lib/aboutyou-sdk/Model/FacetGroup.rb +110 -0
- data/lib/aboutyou-sdk/Model/FacetGroupSet.rb +247 -0
- data/lib/aboutyou-sdk/Model/FacetManager/DefaultFacetManager.rb +79 -0
- data/lib/aboutyou-sdk/Model/Image.rb +134 -0
- data/lib/aboutyou-sdk/Model/ImageSize.rb +21 -0
- data/lib/aboutyou-sdk/Model/InitiateOrder.rb +50 -0
- data/lib/aboutyou-sdk/Model/Order.rb +17 -0
- data/lib/aboutyou-sdk/Model/Product.rb +543 -0
- data/lib/aboutyou-sdk/Model/ProductSearchResult.rb +125 -0
- data/lib/aboutyou-sdk/Model/ProductSearchResult/FacetCount.rb +26 -0
- data/lib/aboutyou-sdk/Model/ProductSearchResult/FacetCounts.rb +38 -0
- data/lib/aboutyou-sdk/Model/ProductSearchResult/PriceRange.rb +49 -0
- data/lib/aboutyou-sdk/Model/ProductSearchResult/SaleCounts.rb +58 -0
- data/lib/aboutyou-sdk/Model/ProductSearchResult/TermsCount.rb +27 -0
- data/lib/aboutyou-sdk/Model/ProductsEansResult.rb +43 -0
- data/lib/aboutyou-sdk/Model/ProductsResult.rb +52 -0
- data/lib/aboutyou-sdk/Model/ResultError.rb +24 -0
- data/lib/aboutyou-sdk/Model/Variant.rb +255 -0
- data/lib/aboutyou-sdk/Model/VariantsResult.rb +102 -0
- data/lib/aboutyou-sdk/Query.rb +261 -0
- data/lib/aboutyou-sdk/QueryBuilder.rb +440 -0
- data/tests/Sinatra-test/Main.rb +5 -0
- data/tests/testApiClient.rb +35 -0
- data/tests/testAutocomplete.rb +40 -0
- data/tests/testCatFilter.rb +35 -0
- data/tests/testCatTree.rb +37 -0
- data/tests/testFacets.rb +36 -0
- data/tests/testProdCatLongestPath.rb +34 -0
- data/tests/testProductSearchResult.rb +35 -0
- data/tests/testProductsByIds.rb +34 -0
- data/tests/testVariantsByIds.rb +34 -0
- metadata +122 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
class ProductSearchResult
|
5
|
+
|
6
|
+
attr_accessor :products
|
7
|
+
attr_accessor :pageHash
|
8
|
+
attr_accessor :productCount
|
9
|
+
attr_accessor :saleCounts
|
10
|
+
attr_accessor :priceRanges
|
11
|
+
attr_accessor :facets
|
12
|
+
attr_accessor :categories
|
13
|
+
attr_accessor :rawFacets
|
14
|
+
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
|
18
|
+
self.products = Array(nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
###
|
22
|
+
# @param \stdClass $jsonObject
|
23
|
+
# @param ModelFactoryInterface $factory
|
24
|
+
#
|
25
|
+
# @return static
|
26
|
+
###
|
27
|
+
def self.createFromJson(jsonObject, factory)
|
28
|
+
productSearchResult = self.new
|
29
|
+
jsonObj = jsonObject
|
30
|
+
|
31
|
+
productSearchResult.pageHash = jsonObj["pageHash"];
|
32
|
+
productSearchResult.productCount = jsonObj["product_count"];
|
33
|
+
productSearchResult.rawFacets = jsonObj["facets"];
|
34
|
+
|
35
|
+
jsonObj["products"].each do |jsonProduct|
|
36
|
+
product = factory.createProduct(jsonProduct)
|
37
|
+
productSearchResult.products.push(product)
|
38
|
+
end
|
39
|
+
productSearchResult.parseFacets(jsonObj["facets"], factory);
|
40
|
+
#free memory
|
41
|
+
jsonObj["categories"] = nil
|
42
|
+
jsonObj["prices"] = nil
|
43
|
+
jsonObj["sale"] = nil
|
44
|
+
productSearchResult.facets= factory.createFacetsCounts(jsonObject)
|
45
|
+
|
46
|
+
return productSearchResult;
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def parseFacets(jsonObject, factory)
|
51
|
+
if (jsonObject["categories"])
|
52
|
+
self.categories = factory.createCategoriesFacets(jsonObject["categories"])
|
53
|
+
end
|
54
|
+
if (jsonObject["prices"])
|
55
|
+
self.priceRanges = factory.createPriceRanges(jsonObject["prices"]);
|
56
|
+
end
|
57
|
+
if (jsonObject["sale"])
|
58
|
+
self.saleCounts = factory.createSaleFacet(jsonObject["sale"]);
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
###
|
64
|
+
# Returns the min price in euro cent or null, if the price range was not requested/selected
|
65
|
+
#
|
66
|
+
# * @return integer|null
|
67
|
+
###
|
68
|
+
def minPrice()
|
69
|
+
|
70
|
+
if (self.priceRanges.empty?)
|
71
|
+
return nil;
|
72
|
+
end
|
73
|
+
|
74
|
+
self.priceRanges.each do |priceRange|
|
75
|
+
if (priceRange.productCount === 0)
|
76
|
+
next;
|
77
|
+
end
|
78
|
+
|
79
|
+
return priceRange.min;
|
80
|
+
end
|
81
|
+
|
82
|
+
return self.priceRanges[0].min
|
83
|
+
end
|
84
|
+
|
85
|
+
###
|
86
|
+
# Returns the max price in euro cent, if the price range was not requested/selected
|
87
|
+
#
|
88
|
+
# @return integer|null
|
89
|
+
###
|
90
|
+
def maxPrice()
|
91
|
+
|
92
|
+
if (self.priceRanges.empty?)
|
93
|
+
return nil;
|
94
|
+
end
|
95
|
+
|
96
|
+
maxPrice = 0;
|
97
|
+
self.priceRanges.reverse_each do |priceRange|
|
98
|
+
if (priceRange.productCount == 0)
|
99
|
+
next;
|
100
|
+
end
|
101
|
+
|
102
|
+
return priceRange.max();
|
103
|
+
end
|
104
|
+
|
105
|
+
return self.priceRanges[-1].max;
|
106
|
+
end
|
107
|
+
|
108
|
+
###
|
109
|
+
# @return Category[]
|
110
|
+
###
|
111
|
+
def categoryTree()
|
112
|
+
|
113
|
+
topLevelCategories = Array(nil);
|
114
|
+
self.categories.each do |category|
|
115
|
+
if (category.parent() == nil)
|
116
|
+
topLevelCategories.push(category);
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
return topLevelCategories;
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
class FacetCount
|
5
|
+
|
6
|
+
# @var Facet */
|
7
|
+
@facet;
|
8
|
+
attr_accessor :facet
|
9
|
+
|
10
|
+
# @var integer */
|
11
|
+
@count;
|
12
|
+
attr_accessor :count
|
13
|
+
|
14
|
+
###
|
15
|
+
# @param Facet $facet
|
16
|
+
# @param integer $count
|
17
|
+
###
|
18
|
+
def initialize(facet, count)
|
19
|
+
|
20
|
+
self.facet = facet;
|
21
|
+
self.count = count;
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
class FacetCounts
|
5
|
+
|
6
|
+
attr_accessor :groupId
|
7
|
+
attr_accessor :facetCountList
|
8
|
+
attr_accessor :productCountTotal
|
9
|
+
attr_accessor :productCountWithoutAnyFacet
|
10
|
+
attr_accessor :productCountWithOtherFacet
|
11
|
+
|
12
|
+
|
13
|
+
def initialize(productCountTotal, productCountWithOtherFacet, productCountWithoutAnyFacet)
|
14
|
+
|
15
|
+
self.productCountTotal = productCountTotal;
|
16
|
+
self.productCountWithOtherFacet = productCountWithOtherFacet;
|
17
|
+
self.productCountWithoutAnyFacet = productCountWithoutAnyFacet;
|
18
|
+
end
|
19
|
+
|
20
|
+
###
|
21
|
+
# @param integer $groupId
|
22
|
+
# @param \stdClass $jsonObject
|
23
|
+
# @param FacetCount[] $facetCounts
|
24
|
+
#
|
25
|
+
# @return FacetCounts
|
26
|
+
###
|
27
|
+
def self.createFromJson(groupId, jsonObject, facetCountList)
|
28
|
+
|
29
|
+
facetCounts = self.new(jsonObject["total"], jsonObject["other"], jsonObject["missing"])
|
30
|
+
facetCounts.groupId = groupId;
|
31
|
+
facetCounts.facetCountList = facetCountList;
|
32
|
+
|
33
|
+
return facetCounts;
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
class PriceRange
|
5
|
+
|
6
|
+
attr_accessor :productCount
|
7
|
+
attr_accessor :from
|
8
|
+
attr_accessor :to
|
9
|
+
attr_accessor :min
|
10
|
+
attr_accessor :max
|
11
|
+
attr_accessor :mean
|
12
|
+
attr_accessor :sum
|
13
|
+
|
14
|
+
|
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
|
+
###
|
32
|
+
def self.createFromJson(jsonObject)
|
33
|
+
|
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"]
|
43
|
+
|
44
|
+
return priceRange;
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
class SaleCounts
|
5
|
+
|
6
|
+
# @var integer */
|
7
|
+
@productCountInSale;
|
8
|
+
attr_accessor :productCountInSale
|
9
|
+
|
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
|
29
|
+
|
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
|
+
return self;
|
40
|
+
end
|
41
|
+
|
42
|
+
###
|
43
|
+
# {@inheritdoc}
|
44
|
+
###
|
45
|
+
def parseTerms(jsonTerms)
|
46
|
+
|
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
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
class TermsCounts
|
5
|
+
|
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
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
class ProductsEansResult
|
5
|
+
|
6
|
+
# @var string[] #
|
7
|
+
attr_accessor :eansNotFound
|
8
|
+
attr_accessor :pageHash
|
9
|
+
attr_accessor :errors
|
10
|
+
|
11
|
+
###
|
12
|
+
# @param \stdClass $jsonObject
|
13
|
+
# @param ModelFactoryInterface $factory
|
14
|
+
#
|
15
|
+
# @return static
|
16
|
+
###
|
17
|
+
def self.createFromJson(jsonObject, factory)
|
18
|
+
|
19
|
+
productsEansResult = self.new
|
20
|
+
|
21
|
+
if jsonObject["pageHash"]
|
22
|
+
productsEansResult.pageHash = jsonObject["pageHash"]
|
23
|
+
else
|
24
|
+
productsEansResult.pageHash = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
if (jsonObject["eans"])
|
28
|
+
jsonObject["eans"].each do |jsonProduct|
|
29
|
+
if (jsonProduct["error_code"])
|
30
|
+
productsEansResult.errors.push(jsonProduct)
|
31
|
+
productsEansResult.eansNotFound = productsEansResult.eansNotFound + jsonProduct["ean"]
|
32
|
+
next;
|
33
|
+
end
|
34
|
+
productsEansResult.products.push = factory.createProduct(jsonProduct);
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
return productsEansResult;
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
class ProductsResult
|
5
|
+
include AbstractModel
|
6
|
+
|
7
|
+
attr_accessor :idsNotFound
|
8
|
+
attr_accessor :pageHash
|
9
|
+
attr_accessor :errors
|
10
|
+
attr_accessor :products
|
11
|
+
|
12
|
+
|
13
|
+
###
|
14
|
+
# @param \stdClass $jsonObject
|
15
|
+
# @param ModelFactoryInterface $factory
|
16
|
+
#
|
17
|
+
# @return static
|
18
|
+
###
|
19
|
+
def self.createFromJson(jsonObject, factory)
|
20
|
+
|
21
|
+
productsResult = self.new
|
22
|
+
|
23
|
+
productsResult.pageHash = (jsonObject["pageHash"]) ? jsonObject["pageHash"] : nil;
|
24
|
+
productsResult.errors=Array(nil)
|
25
|
+
productsResult.idsNotFound=Array(nil)
|
26
|
+
productsResult.products = Hash.new
|
27
|
+
|
28
|
+
if (jsonObject["ids"])
|
29
|
+
jsonObject["ids"].each do |key, jsonProduct|
|
30
|
+
if (jsonProduct["error_code"])
|
31
|
+
productsResult.idsNotFound.push(key)
|
32
|
+
productsResult.errors.push(jsonProduct);
|
33
|
+
next
|
34
|
+
end
|
35
|
+
productsResult.products[Integer(key)] = factory.createProduct(jsonProduct);
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
return productsResult;
|
40
|
+
end
|
41
|
+
|
42
|
+
###
|
43
|
+
# @return integer[] array of product ids
|
44
|
+
###
|
45
|
+
def getProductsNotFound()
|
46
|
+
|
47
|
+
return self.idsNotFound;
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module AboutYou
|
2
|
+
module SDK
|
3
|
+
module Model
|
4
|
+
module ResultError
|
5
|
+
|
6
|
+
attr_accessor :errorIdent
|
7
|
+
attr_accessor :errorCode
|
8
|
+
attr_accessor :errorMessage
|
9
|
+
|
10
|
+
def initialize(jsonObject)
|
11
|
+
|
12
|
+
self.parseErrorResult(jsonObject);
|
13
|
+
end
|
14
|
+
|
15
|
+
def parseErrorResult(jsonObject)
|
16
|
+
|
17
|
+
self.errorIdent = (jsonObject.key?("error_ident")) ? String(jsonObject["error_ident"]) : nil;
|
18
|
+
self.errorCode = (jsonObject.key?("error_code")) ? Integer(jsonObject["error_code"]) : 0;
|
19
|
+
self.errorMessage = (jsonObject.key?("error_message")) ? jsonObject["error_message"] : nil;
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|