aboutyou-sdk 0.0.22 → 0.0.23

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWI0ZDkyZTNmMTZiMjg0NzQ4ZTA2ZDMzMDM2ZGFjMTVjMDE5ZjVkMA==
4
+ OTE1YWM2YjQ2NmIwYTM4Y2Q3OTcxOWVkZGQzNDQwZDVlZjkxMzhlYg==
5
5
  data.tar.gz: !binary |-
6
- MTRmMDE3YmUzMmY3ZDIyNDZlNzkwOWUzZWVkNDk4YmE5MDkyMjUxNg==
6
+ M2NmOTMwYTdmNzEyZTc2MjQyNmY5ZDQ4MGU3YjQyNDEwYWJkYjU2OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDE1MzliMjk0OWRlMDllNmI1MzUxNTEyMjM3MjE0OTkyMjgzOTU3ZmI5ZjVk
10
- ODllYzAyNjNkMGQ1YzFmZjI5NzE5MTAxZTExN2I1MDM2MDVkYWRmOGYwZTdj
11
- OTEzOTBmODcwOTY5ZTA1NTE2N2QzNjE3ZGQxMjI3MjdkMDFiYmI=
9
+ OGYzMTc2MTU2YjU5YzY2MjE5ZWFiMDc5ZTkxZjY3MDhjZThjZTA3MWZjMjJl
10
+ NDlmNmEyZWEwNGU4MTNiYzk2OGQ5ZTBkMjYyODQ5ZWFkNzAxMGM5ZGQ5M2Nj
11
+ N2YxYjQwZmY0YmJkYmJiZWE0NzVjODU3ZDhjMmZlZDRiYmE0YWM=
12
12
  data.tar.gz: !binary |-
13
- ZWI3ZDNlNGNiMTA5NjkwNTNhZjNkOGVjYjZhMTA0NWVlNzY3ZjlkYWM2MWMy
14
- ZDI0N2FmNWZlZmEwZDA3ZmU2ZTYzOTYwNmI3MTRhY2Y2MTBhMGI4MjEwOWQ5
15
- YzI4YTQ5NDk2MzNjODI3NTg4ZGUwNDcyN2Y4YmIyNTU2OGExMjY=
13
+ NDdkYzJlN2UxN2YwYWE2NDNjMjc0NTA0ZjAzYTQyODFhZWQ2ODRkNTQ0ZGFl
14
+ YjRkODY3YTEzMjBmZWE3YWM1M2IzMGRhNTg1YmZlNGY5OGFhZDdjNWFjMGU3
15
+ YjYyYTZmN2M1YWQxM2MxMTZjODUzZDRjMjQwNGVjYjNmMDYyM2Q=
data/lib/aboutyou-sdk.rb CHANGED
@@ -1,9 +1,6 @@
1
1
  require 'httparty'
2
2
  require 'json'
3
3
  require 'require_all'
4
- require 'dalli'
5
- require 'redis'
6
-
7
4
 
8
5
  require_rel 'aboutyou-sdk'
9
6
 
@@ -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
- # @var ShopApi #
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
- attr_accessor :id
7
- attr_accessor :logoUrl
8
- attr_accessor :name
9
- attr_accessor :url
10
- attr_accessor :privacyStatementUrl
11
- attr_accessor :tosUrl
12
-
13
-
14
- ###
15
- # @param \stdClass $json
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
- app.id = json["id"];
24
- app.logoUrl = json["logo_url"]
25
- app.name = json["name"]
26
- app.url = json["url"]
27
- app.privacyStatementUrl = json["privacy_statement_url"]
28
- app.tosUrl = json["tos_url"]
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
- return app;
31
- end
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
- self.categories = categories;
21
- self.products = products;
29
+ self.categories = categories
30
+ self.products = products
22
31
  end
23
32
 
24
- ###
25
- # @param \stdClass $jsonObject The autocomplete data.
26
- # @param ModelFactoryInterface $factory
27
- #
28
- # @return static
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
- # parse autocompleted categories.
39
- #
40
- #
41
- # @param \stdClass $jsonObject
42
- # @param ModelFactoryInterface $factory
43
- #
44
- # @return Category[]|null
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
- if !(jsonObject.key?('categories'))
49
- return NOT_REQUESTED;
50
- end
58
+ unless jsonObject.key?('categories')
59
+ return NOT_REQUESTED
60
+ end
51
61
 
52
- if (jsonObject["categories"] == nil)
53
- return Array(nil);
54
- end
62
+ if jsonObject["categories"] == nil
63
+ return []
64
+ end
55
65
 
56
- categories = Array(nil)
57
- jsonObject["categories"].each do |category|
58
- categories.push(factory.createCategory(category))
59
- end
66
+ categories = []
67
+ jsonObject["categories"].each do |category|
68
+ categories.push(factory.createCategory(category))
69
+ end
60
70
 
61
- return categories;
71
+ categories
62
72
  end
63
73
 
64
- ###
65
- # parse autocompleted products.
66
- #
67
- # @param \stdClass $jsonObject
68
- # @param ModelFactoryInterface $factory
69
- #
70
- # @return Products[]
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
- if !(jsonObject.key?('products'))
75
- return NOT_REQUESTED;
76
- end
85
+ unless jsonObject.key?('products')
86
+ return NOT_REQUESTED
87
+ end
77
88
 
78
- if (jsonObject["products"] == nil)
79
- return Array(nil);
80
- end
89
+ if jsonObject["products"] == nil
90
+ return []
91
+ end
81
92
 
82
- products = Array(nil);
83
- jsonObject["products"].each do |product|
84
- products.push(factory.createProduct(product))
85
- end
93
+ products = []
94
+ jsonObject["products"].each do |product|
95
+ products.push(factory.createProduct(product))
96
+ end
86
97
 
87
- return products;
98
+ products
88
99
  end
89
100
  end
90
101
  end