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
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTE1YWM2YjQ2NmIwYTM4Y2Q3OTcxOWVkZGQzNDQwZDVlZjkxMzhlYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2NmOTMwYTdmNzEyZTc2MjQyNmY5ZDQ4MGU3YjQyNDEwYWJkYjU2OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGYzMTc2MTU2YjU5YzY2MjE5ZWFiMDc5ZTkxZjY3MDhjZThjZTA3MWZjMjJl
|
10
|
+
NDlmNmEyZWEwNGU4MTNiYzk2OGQ5ZTBkMjYyODQ5ZWFkNzAxMGM5ZGQ5M2Nj
|
11
|
+
N2YxYjQwZmY0YmJkYmJiZWE0NzVjODU3ZDhjMmZlZDRiYmE0YWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDdkYzJlN2UxN2YwYWE2NDNjMjc0NTA0ZjAzYTQyODFhZWQ2ODRkNTQ0ZGFl
|
14
|
+
YjRkODY3YTEzMjBmZWE3YWM1M2IzMGRhNTg1YmZlNGY5OGFhZDdjNWFjMGU3
|
15
|
+
YjYyYTZmN2M1YWQxM2MxMTZjODUzZDRjMjQwNGVjYjNmMDYyM2Q=
|
data/lib/aboutyou-sdk.rb
CHANGED
@@ -1,24 +1,82 @@
|
|
1
1
|
module AboutYou
|
2
2
|
module SDK
|
3
3
|
module CacheProvider
|
4
|
+
|
5
|
+
###
|
6
|
+
# This class is used as an interface for cache operations.
|
7
|
+
# It is used when caching with Dalli.
|
8
|
+
#
|
9
|
+
# author:: Collins GmbH & Co KG
|
10
|
+
###
|
4
11
|
class Dalli
|
12
|
+
require 'dalli'
|
13
|
+
|
14
|
+
# an instance of the cache client.
|
5
15
|
attr_accessor :client
|
16
|
+
|
17
|
+
###
|
18
|
+
# the Constructor for the Dalli class
|
19
|
+
#
|
20
|
+
# * *Args* :
|
21
|
+
# - +client+ -> an instance of Dalli::Client
|
22
|
+
#
|
23
|
+
# * *Returns* :
|
24
|
+
# - Instance of AboutYou::SDK::CacheProvider::Dalli
|
25
|
+
###
|
6
26
|
def initialize(client)
|
7
27
|
self.client = client
|
8
28
|
end
|
9
29
|
|
30
|
+
###
|
31
|
+
# This method is used for setting new cache entries with Dalli.
|
32
|
+
#
|
33
|
+
# * *Args* :
|
34
|
+
# - +key+ -> The key of the cache entry
|
35
|
+
# - +value+ -> The value of the cache entry
|
36
|
+
# - +duration+ -> the duration of the cache entry
|
37
|
+
#
|
38
|
+
# * *Returns* :
|
39
|
+
# - True/False determining whether the setting was successfull of not
|
40
|
+
###
|
10
41
|
def set(key, value, duration)
|
11
42
|
self.client.set(key, value, duration)
|
12
43
|
end
|
13
44
|
|
45
|
+
###
|
46
|
+
# This method is used for getting cache entries with Dalli.
|
47
|
+
#
|
48
|
+
# * *Args* :
|
49
|
+
# - +key+ -> The key of the cache entry
|
50
|
+
#
|
51
|
+
# * *Returns* :
|
52
|
+
# - Either the value for the given key or nil if the key was not found
|
53
|
+
###
|
14
54
|
def get(key)
|
15
55
|
self.client.get(key)
|
16
56
|
end
|
17
57
|
|
58
|
+
###
|
59
|
+
# This method is used for deleting cache entries with Dalli.
|
60
|
+
#
|
61
|
+
# * *Args* :
|
62
|
+
# - +key+ -> The key of the cache entry
|
63
|
+
#
|
64
|
+
# * *Returns* :
|
65
|
+
# - True/False determining whether the deletion was successfull or not
|
66
|
+
###
|
18
67
|
def delete(key)
|
19
68
|
self.client.delete(key)
|
20
69
|
end
|
21
70
|
|
71
|
+
###
|
72
|
+
# This method is used for checking whether a cache entry exists or not with Dalli.
|
73
|
+
#
|
74
|
+
# * *Args* :
|
75
|
+
# - +key+ -> The key of the cache entry
|
76
|
+
#
|
77
|
+
# * *Returns* :
|
78
|
+
# - True/False determining whether the key exists in the cache or not
|
79
|
+
###
|
22
80
|
def exists(key)
|
23
81
|
self.client.get(key) != nil
|
24
82
|
end
|
@@ -1,26 +1,84 @@
|
|
1
1
|
module AboutYou
|
2
2
|
module SDK
|
3
3
|
module CacheProvider
|
4
|
+
|
5
|
+
###
|
6
|
+
# This class is used as an interface for cache operations.
|
7
|
+
# It is used when caching with Redis.
|
8
|
+
#
|
9
|
+
# author:: Collins GmbH & Co KG
|
10
|
+
###
|
4
11
|
class Redis
|
12
|
+
require 'redis'
|
13
|
+
|
14
|
+
# an instance of the cache client.
|
5
15
|
attr_accessor :client
|
16
|
+
|
17
|
+
###
|
18
|
+
# the Constructor for the Redis class
|
19
|
+
#
|
20
|
+
# * *Args* :
|
21
|
+
# - +client+ -> an instance of Redis
|
22
|
+
#
|
23
|
+
# * *Returns* :
|
24
|
+
# - Instance of AboutYou::SDK::CacheProvider::Redis
|
25
|
+
###
|
6
26
|
def initialize(client)
|
7
27
|
self.client = client
|
8
28
|
end
|
9
29
|
|
30
|
+
###
|
31
|
+
# This method is used for setting new cache entries with Redis.
|
32
|
+
#
|
33
|
+
# * *Args* :
|
34
|
+
# - +key+ -> The key of the cache entry
|
35
|
+
# - +value+ -> The value of the cache entry
|
36
|
+
# - +duration+ -> the duration of the cache entry
|
37
|
+
#
|
38
|
+
# * *Returns* :
|
39
|
+
# - True/False determining whether the setting was successfull of not
|
40
|
+
###
|
10
41
|
def set(key, value, duration)
|
11
42
|
value = value.to_json unless value.is_a?(String)
|
12
43
|
self.client.set(key, value)
|
13
44
|
self.client.expire(key, duration)
|
14
45
|
end
|
15
46
|
|
47
|
+
###
|
48
|
+
# This method is used for getting cache entries with Redis.
|
49
|
+
#
|
50
|
+
# * *Args* :
|
51
|
+
# - +key+ -> The key of the cache entry
|
52
|
+
#
|
53
|
+
# * *Returns* :
|
54
|
+
# - Either the value for the given key or nil if the key was not found
|
55
|
+
###
|
16
56
|
def get(key)
|
17
57
|
JSON.parse(self.client.get(key))
|
18
58
|
end
|
19
59
|
|
60
|
+
###
|
61
|
+
# This method is used for deleting cache entries with Redis.
|
62
|
+
#
|
63
|
+
# * *Args* :
|
64
|
+
# - +key+ -> The key of the cache entry
|
65
|
+
#
|
66
|
+
# * *Returns* :
|
67
|
+
# - True/False determining whether the deletion was successfull or not
|
68
|
+
###
|
20
69
|
def delete(key)
|
21
70
|
self.client.del(key)
|
22
71
|
end
|
23
72
|
|
73
|
+
###
|
74
|
+
# This method is used for checking whether a cache entry exists or not with Redis.
|
75
|
+
#
|
76
|
+
# * *Args* :
|
77
|
+
# - +key+ -> The key of the cache entry
|
78
|
+
#
|
79
|
+
# * *Returns* :
|
80
|
+
# - True/False determining whether the key exists in the cache or not
|
81
|
+
###
|
24
82
|
def exists(key)
|
25
83
|
self.client.exists(key)
|
26
84
|
end
|
@@ -1,25 +1,14 @@
|
|
1
1
|
module AboutYou
|
2
2
|
module SDK
|
3
3
|
module Model
|
4
|
+
|
5
|
+
###
|
6
|
+
# This Module is abstract and represents a model which has a shopApi attribute
|
7
|
+
#
|
8
|
+
# author:: Collins GmbH & Co KG
|
9
|
+
###
|
4
10
|
module AbstractModel
|
5
|
-
|
6
|
-
@shopApi
|
7
|
-
|
8
|
-
###
|
9
|
-
# @param ShopApi $shopApi
|
10
|
-
###
|
11
|
-
def shopApi=(shopApi)
|
12
|
-
|
13
|
-
@shopApi = shopApi;
|
14
|
-
end
|
15
|
-
|
16
|
-
###
|
17
|
-
# @return ShopApi
|
18
|
-
###
|
19
|
-
def shopApi()
|
20
|
-
|
21
|
-
@shopApi;
|
22
|
-
end
|
11
|
+
attr_accessor :shopApi
|
23
12
|
end
|
24
13
|
end
|
25
14
|
end
|
@@ -1,34 +1,46 @@
|
|
1
1
|
module AboutYou
|
2
2
|
module SDK
|
3
|
-
module Model
|
3
|
+
module Model
|
4
|
+
###
|
5
|
+
# This Class represents an app model
|
6
|
+
#
|
7
|
+
# author:: Collins GmbH & Co KG
|
8
|
+
###
|
4
9
|
class App
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# @return static
|
18
|
-
###
|
19
|
-
def self.createFromJson(json)
|
20
|
-
|
21
|
-
app = self.new
|
10
|
+
# the id of the app
|
11
|
+
attr_accessor :id
|
12
|
+
# the logo url of the app
|
13
|
+
attr_accessor :logoUrl
|
14
|
+
# the name of the app
|
15
|
+
attr_accessor :name
|
16
|
+
# the url of the app
|
17
|
+
attr_accessor :url
|
18
|
+
# the privacy statement url
|
19
|
+
attr_accessor :privacyStatementUrl
|
20
|
+
# the tearms of service url
|
21
|
+
attr_accessor :tosUrl
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
###
|
24
|
+
# This method is used for creating an instance of this class by a jsonObject.
|
25
|
+
#
|
26
|
+
# * *Args* :
|
27
|
+
# - +json+ -> the jsonObject received from the api
|
28
|
+
#
|
29
|
+
# * *Returns* :
|
30
|
+
# - Instance of AboutYou::SDK::Model::App
|
31
|
+
###
|
32
|
+
def self.createFromJson(json)
|
33
|
+
app = self.new
|
29
34
|
|
30
|
-
|
31
|
-
|
35
|
+
app.id = json["id"]
|
36
|
+
app.logoUrl = json["logo_url"]
|
37
|
+
app.name = json["name"]
|
38
|
+
app.url = json["url"]
|
39
|
+
app.privacyStatementUrl = json["privacy_statement_url"]
|
40
|
+
app.tosUrl = json["tos_url"]
|
41
|
+
|
42
|
+
app
|
43
|
+
end
|
32
44
|
end
|
33
45
|
end
|
34
46
|
end
|
@@ -1,90 +1,101 @@
|
|
1
1
|
module AboutYou
|
2
2
|
module SDK
|
3
3
|
module Model
|
4
|
+
###
|
5
|
+
# This Class represents an autocomplete model
|
6
|
+
#
|
7
|
+
# author:: Collins GmbH & Co KG
|
8
|
+
###
|
4
9
|
class Autocomplete
|
5
|
-
|
6
|
-
NOT_REQUESTED = nil
|
10
|
+
# this constant is used for values which are not requested
|
11
|
+
NOT_REQUESTED = nil
|
7
12
|
|
8
|
-
|
9
|
-
# @var Product[]
|
10
|
-
###
|
13
|
+
# the products of the autocomplete
|
11
14
|
attr_accessor :products
|
12
|
-
|
13
|
-
###
|
14
|
-
# @var Category[]
|
15
|
-
###
|
15
|
+
# the categories of the autocomplete
|
16
16
|
attr_accessor :categories
|
17
17
|
|
18
|
+
###
|
19
|
+
# the Constructor for the autocomplete class
|
20
|
+
#
|
21
|
+
# * *Args* :
|
22
|
+
# - +productCountTotal+ -> the total productcount
|
23
|
+
# - +productCountWithOtherFacet+ -> the productcount without any facets
|
24
|
+
#
|
25
|
+
# * *Returns* :
|
26
|
+
# - Instance of AboutYou::SDK::Model::AutoComplete
|
27
|
+
###
|
18
28
|
def initialize(categories = nil, products = nil)
|
19
|
-
|
20
|
-
|
21
|
-
self.products = products;
|
29
|
+
self.categories = categories
|
30
|
+
self.products = products
|
22
31
|
end
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
33
|
+
###
|
34
|
+
# This method lets you build an autocomplete model by a json response from the api
|
35
|
+
#
|
36
|
+
# * *Args* :
|
37
|
+
# - +jsonObject+ -> the json response from the api
|
38
|
+
# - +factory+ -> the model factory responsible for building the models
|
39
|
+
#
|
40
|
+
# * *Returns* :
|
41
|
+
# - Instance of AboutYou::SDK::Model::AutoComplete
|
42
|
+
###
|
30
43
|
def self.createFromJson(jsonObject, factory)
|
31
|
-
|
32
|
-
autocomplete = self.new(parseCategories(jsonObject, factory), parseProducts(jsonObject, factory))
|
33
|
-
|
34
|
-
return autocomplete;
|
44
|
+
self.new(parseCategories(jsonObject, factory), parseProducts(jsonObject, factory))
|
35
45
|
end
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
###
|
48
|
+
# This method parses the json object and builds category models from it
|
49
|
+
#
|
50
|
+
# * *Args* :
|
51
|
+
# - +jsonObject+ -> the json response from the api
|
52
|
+
# - +factory+ -> the model factory responsible for building the models
|
53
|
+
#
|
54
|
+
# * *Returns* :
|
55
|
+
# - Array containing instances of AboutYou::SDK::Model::Category
|
56
|
+
###
|
46
57
|
def self.parseCategories(jsonObject, factory)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
58
|
+
unless jsonObject.key?('categories')
|
59
|
+
return NOT_REQUESTED
|
60
|
+
end
|
51
61
|
|
52
|
-
|
53
|
-
|
54
|
-
|
62
|
+
if jsonObject["categories"] == nil
|
63
|
+
return []
|
64
|
+
end
|
55
65
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
66
|
+
categories = []
|
67
|
+
jsonObject["categories"].each do |category|
|
68
|
+
categories.push(factory.createCategory(category))
|
69
|
+
end
|
60
70
|
|
61
|
-
|
71
|
+
categories
|
62
72
|
end
|
63
73
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
###
|
75
|
+
# This method parses the json object and builds product models from it
|
76
|
+
#
|
77
|
+
# * *Args* :
|
78
|
+
# - +jsonObject+ -> the json response from the api
|
79
|
+
# - +factory+ -> the model factory responsible for building the models
|
80
|
+
#
|
81
|
+
# * *Returns* :
|
82
|
+
# - Array containing instances of AboutYou::SDK::Model::Product
|
83
|
+
###
|
72
84
|
def self.parseProducts(jsonObject, factory)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
85
|
+
unless jsonObject.key?('products')
|
86
|
+
return NOT_REQUESTED
|
87
|
+
end
|
77
88
|
|
78
|
-
|
79
|
-
|
80
|
-
|
89
|
+
if jsonObject["products"] == nil
|
90
|
+
return []
|
91
|
+
end
|
81
92
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
93
|
+
products = []
|
94
|
+
jsonObject["products"].each do |product|
|
95
|
+
products.push(factory.createProduct(product))
|
96
|
+
end
|
86
97
|
|
87
|
-
|
98
|
+
products
|
88
99
|
end
|
89
100
|
end
|
90
101
|
end
|