aboutyou-sdk 0.0.2 → 0.0.3
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 +8 -8
- data/lib/aboutyou-sdk.rb +3 -3
- data/lib/aboutyou-sdk/Factory/DefaultModelFactory.rb +4 -4
- data/lib/aboutyou-sdk/Model/ProductsEansResult.rb +5 -1
- data/lib/aboutyou-sdk/Query.rb +7 -5
- data/lib/aboutyou-sdk/QueryBuilder.rb +13 -11
- data/tests/testFacetTypes.rb +33 -0
- data/tests/testFacets.rb +1 -1
- data/tests/testFetchFacet.rb +33 -0
- data/tests/testJavaScript.rb +17 -0
- data/tests/testProductsByEans.rb +37 -0
- data/tests/testProductsByIds.rb +7 -5
- data/tests/testSuggest.rb +33 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzNjMzMyNDQzNWNiMWVkNDgxZTYxNTI4NTc3YWY2ZGY3Njk0YjVhNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTEyOTg3OGIwN2NjZWNkYTI0MTMwMDFkOTZiNjI0OGU3ZDE2Y2M0Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzFkNDBlMDViMWY3NjFmMWE3ZWFhNjY0ZWFlODBlMTcxMzVjM2E2YWVhMTFh
|
10
|
+
NGMyN2Y3NmMxM2I1NjhlMjY2OWU5MDE5ZGE3MTFkN2I0NjYyNjEwMjRkYTUw
|
11
|
+
MTIyMzVjNjc1ZjFjMDI2YWQ2Y2EzYTZlN2VhYzgwYjEwNDI0YWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDEzMDE2NDgxMWRlZDczZmE3MzBmNzU1ZjU0Njk0ZTI2Njc3ZWNlY2FiMzBm
|
14
|
+
ZWIxZTJiZmU3YTc4NzlmZjljODIyNjdhNGNlZGI3MzRjZDc0NDljNzI2ZDA2
|
15
|
+
MTM5OWE1MjhhYmMxNWExNjUwOTgwMDE1ZmY1MGE3OGNjY2VlZGY=
|
data/lib/aboutyou-sdk.rb
CHANGED
@@ -36,7 +36,7 @@ class AY
|
|
36
36
|
# @param LoggerInterface $logger
|
37
37
|
# @param \Aboutyou\Common\Cache\CacheMultiGet|\Doctrine\Common\Cache\CacheMultiGet $facetManagerCache
|
38
38
|
###
|
39
|
-
def initialize(appId,appPassword,apiEndPoint = AboutYou::SDK::Constants::API_ENVIRONMENT_LIVE, resultFactory = nil, logger = nil,facetManagerCache = nil
|
39
|
+
def initialize(appId,appPassword,sessionId = 'SESSION_ID', apiEndPoint = AboutYou::SDK::Constants::API_ENVIRONMENT_LIVE, resultFactory = nil, logger = nil,facetManagerCache = nil)
|
40
40
|
aboutYouClient = AboutYou::SDK::Client.new(appId, appPassword, apiEndPoint, logger)
|
41
41
|
|
42
42
|
if (apiEndPoint === AboutYou::SDK::Constants::API_ENVIRONMENT_STAGE)
|
@@ -340,7 +340,7 @@ class AY
|
|
340
340
|
# @throws ShopApi\Exception\MalformedJsonException
|
341
341
|
#@throws ShopApi\Exception\UnexpectedResultException
|
342
342
|
###
|
343
|
-
def fetchFacets(groupIds=nil)
|
343
|
+
def fetchFacets(groupIds=Array(nil))
|
344
344
|
|
345
345
|
query = query().fetchFacets(groupIds)
|
346
346
|
|
@@ -385,7 +385,7 @@ class AY
|
|
385
385
|
# @throws ShopApi\Exception\UnexpectedResultException
|
386
386
|
###
|
387
387
|
def fetchFacet(params)
|
388
|
-
|
388
|
+
|
389
389
|
query = query().fetchFacet(params)
|
390
390
|
|
391
391
|
query.executeSingle()
|
@@ -114,7 +114,7 @@ module AboutYou
|
|
114
114
|
#
|
115
115
|
# @return ShopApi\Model\Facet[]
|
116
116
|
###
|
117
|
-
def createFacetList(jsonArray)
|
117
|
+
def createFacetList(jsonArray, query)
|
118
118
|
|
119
119
|
facets = Hash.new
|
120
120
|
jsonArray.each do |jsonFacet|
|
@@ -183,7 +183,7 @@ module AboutYou
|
|
183
183
|
#
|
184
184
|
# @return integer[]
|
185
185
|
###
|
186
|
-
def createFacetTypes(jsonArray)
|
186
|
+
def createFacetTypes(jsonArray, query)
|
187
187
|
|
188
188
|
return jsonArray;
|
189
189
|
end
|
@@ -279,7 +279,7 @@ module AboutYou
|
|
279
279
|
#
|
280
280
|
# @return ShopApi\Model\ProductsEansResult
|
281
281
|
###
|
282
|
-
def createProductsEansResult(jsonObject)
|
282
|
+
def createProductsEansResult(jsonObject, query)
|
283
283
|
|
284
284
|
return AboutYou::SDK::Model::ProductsEansResult.createFromJson(jsonObject, self)
|
285
285
|
end
|
@@ -308,7 +308,7 @@ module AboutYou
|
|
308
308
|
#
|
309
309
|
# @return string[]
|
310
310
|
###
|
311
|
-
def createSuggest(jsonArray)
|
311
|
+
def createSuggest(jsonArray, query)
|
312
312
|
|
313
313
|
return jsonArray;
|
314
314
|
end
|
@@ -7,6 +7,7 @@ module AboutYou
|
|
7
7
|
attr_accessor :eansNotFound
|
8
8
|
attr_accessor :pageHash
|
9
9
|
attr_accessor :errors
|
10
|
+
attr_accessor :products
|
10
11
|
|
11
12
|
###
|
12
13
|
# @param \stdClass $jsonObject
|
@@ -17,6 +18,9 @@ module AboutYou
|
|
17
18
|
def self.createFromJson(jsonObject, factory)
|
18
19
|
|
19
20
|
productsEansResult = self.new
|
21
|
+
productsEansResult.products = Array(nil)
|
22
|
+
productsEansResult.eansNotFound = Array(nil)
|
23
|
+
productsEansResult.errors = Array(nil)
|
20
24
|
|
21
25
|
if jsonObject["pageHash"]
|
22
26
|
productsEansResult.pageHash = jsonObject["pageHash"]
|
@@ -31,7 +35,7 @@ module AboutYou
|
|
31
35
|
productsEansResult.eansNotFound = productsEansResult.eansNotFound + jsonProduct["ean"]
|
32
36
|
next;
|
33
37
|
end
|
34
|
-
productsEansResult.products.push
|
38
|
+
productsEansResult.products.push(factory.createProduct(jsonProduct));
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
data/lib/aboutyou-sdk/Query.rb
CHANGED
@@ -234,11 +234,13 @@ module AboutYou
|
|
234
234
|
jsonObject = responseObject[resultKey]
|
235
235
|
queryKey = currentQuery.keys[0]
|
236
236
|
factory = self.factory
|
237
|
-
if (
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
237
|
+
if !(queryKey == "facet_types" || queryKey == "suggest" || queryKey == "facet")
|
238
|
+
if (jsonObject['error_code'])
|
239
|
+
result = factory.preHandleError(jsonObject, resultKey, isMultiRequest);
|
240
|
+
if (result != false)
|
241
|
+
results.push(Hash[resultKey=> result])
|
242
|
+
next
|
243
|
+
end
|
242
244
|
end
|
243
245
|
end
|
244
246
|
query = currentQuery[queryKey];
|
@@ -216,7 +216,7 @@ module AboutYou
|
|
216
216
|
ids = Array(ids)
|
217
217
|
|
218
218
|
ids.each do |id|
|
219
|
-
id = id
|
219
|
+
id = Integer(id)
|
220
220
|
if (id < 1)
|
221
221
|
raise 'InvalidArgumentException! A single category ID must be greater than 0'
|
222
222
|
end
|
@@ -258,7 +258,7 @@ module AboutYou
|
|
258
258
|
ids = Array(ids)
|
259
259
|
ids = ids.map{|id| Integer(id)}
|
260
260
|
|
261
|
-
self.query.push(Hash['products' => Hash['ids' => ids,'fields' => AboutYou::SDK::Criteria::ProductFields
|
261
|
+
self.query.push(Hash['products' => Hash['ids' => ids,'fields' => AboutYou::SDK::Criteria::ProductFields.filterFields(fields)]])
|
262
262
|
|
263
263
|
return self;
|
264
264
|
end
|
@@ -274,7 +274,7 @@ module AboutYou
|
|
274
274
|
|
275
275
|
ids = ids.map{|id| Integer(id)}
|
276
276
|
|
277
|
-
self.query.push(Hash['live_variant' => Hash['ids'
|
277
|
+
self.query.push(Hash['live_variant' => Hash['ids' => ids]])
|
278
278
|
|
279
279
|
return self;
|
280
280
|
end
|
@@ -289,7 +289,7 @@ module AboutYou
|
|
289
289
|
self.query.push(Hash[
|
290
290
|
'products_eans' => Hash[
|
291
291
|
'eans' => eans,
|
292
|
-
'fields' => ProductFields
|
292
|
+
'fields' => AboutYou::SDK::Criteria::ProductFields.filterFields(fields),
|
293
293
|
'version' => '2'
|
294
294
|
]
|
295
295
|
]
|
@@ -342,7 +342,7 @@ module AboutYou
|
|
342
342
|
def fetchProductSearch(criteria)
|
343
343
|
|
344
344
|
checkSessionId(criteria.sessionId());
|
345
|
-
self.query.push(Hash['product_search' =>criteria
|
345
|
+
self.query.push(Hash['product_search' =>Array(criteria)])
|
346
346
|
|
347
347
|
return self;
|
348
348
|
end
|
@@ -354,12 +354,14 @@ module AboutYou
|
|
354
354
|
#
|
355
355
|
# @throws \InvalidArgumentException
|
356
356
|
###
|
357
|
-
def fetchFacets(groupIds = Array())
|
357
|
+
def fetchFacets(groupIds = Array(nil))
|
358
358
|
|
359
|
-
|
360
|
-
|
361
|
-
|
359
|
+
if(groupIds)
|
360
|
+
groupids = groupIds.map{|groupId| Integer(groupId)}
|
361
|
+
end
|
362
362
|
|
363
|
+
self.query.push(Hash['facets' => Hash['group_ids' => groupids]])
|
364
|
+
binding.pry
|
363
365
|
return self;
|
364
366
|
end
|
365
367
|
|
@@ -372,11 +374,11 @@ module AboutYou
|
|
372
374
|
###
|
373
375
|
def fetchFacet(params)
|
374
376
|
|
375
|
-
if (params.empty)
|
377
|
+
if (params.empty?)
|
376
378
|
raise 'InvalidArgumentException! no params given'
|
377
379
|
end
|
378
380
|
|
379
|
-
|
381
|
+
self.query.push(Hash['facet' => params])
|
380
382
|
|
381
383
|
return self
|
382
384
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'pry_debug'
|
3
|
+
require_relative '../lib/aboutyou-sdk.rb'
|
4
|
+
|
5
|
+
class AY
|
6
|
+
attr_accessor :result
|
7
|
+
|
8
|
+
def putsCatName(category)
|
9
|
+
category = Array(category)
|
10
|
+
self.result = self.result + '<ul>'
|
11
|
+
category.each do |cat|
|
12
|
+
self.result = self.result + ('<li>'+cat.name+'</li>')
|
13
|
+
if (cat.subCategories(true))
|
14
|
+
putsCatName(cat.subCategories(true))
|
15
|
+
else
|
16
|
+
puts ""
|
17
|
+
end
|
18
|
+
end
|
19
|
+
self.result = self.result + '</ul>'
|
20
|
+
return result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
shop = AY.new(281, 'e6068c4ca020262613d06122663cb300')
|
25
|
+
shop.result = ""
|
26
|
+
|
27
|
+
result = shop.fetchFacetTypes
|
28
|
+
result.each do |facetId|
|
29
|
+
shop.result = shop.result + String(facetId) + '</br>'
|
30
|
+
end
|
31
|
+
get "/" do
|
32
|
+
return shop.result
|
33
|
+
end
|
data/tests/testFacets.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'pry_debug'
|
3
|
+
require_relative '../lib/aboutyou-sdk.rb'
|
4
|
+
|
5
|
+
class AY
|
6
|
+
attr_accessor :result
|
7
|
+
|
8
|
+
def putsCatName(category)
|
9
|
+
category = Array(category)
|
10
|
+
self.result = self.result + '<ul>'
|
11
|
+
category.each do |cat|
|
12
|
+
self.result = self.result + ('<li>'+cat.name+'</li>')
|
13
|
+
if (cat.subCategories(true))
|
14
|
+
putsCatName(cat.subCategories(true))
|
15
|
+
else
|
16
|
+
puts ""
|
17
|
+
end
|
18
|
+
end
|
19
|
+
self.result = self.result + '</ul>'
|
20
|
+
return result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
shop = AY.new(281, 'e6068c4ca020262613d06122663cb300')
|
25
|
+
shop.result = ""
|
26
|
+
|
27
|
+
result = shop.fetchFacet([Hash["id" => 426, "group_id" => 1]])
|
28
|
+
result.each do |key, facet|
|
29
|
+
shop.result = shop.result + facet.name + '</br>'
|
30
|
+
end
|
31
|
+
get "/" do
|
32
|
+
return shop.result
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'pry_debug'
|
3
|
+
require_relative '../lib/aboutyou-sdk.rb'
|
4
|
+
|
5
|
+
class AY
|
6
|
+
attr_accessor :result
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
shop = AY.new(281, 'e6068c4ca020262613d06122663cb300')
|
11
|
+
shop.result = ""
|
12
|
+
|
13
|
+
shop.result = shop.result + shop.javaScriptTag + '</br>'
|
14
|
+
shop.result = shop.result + shop.javaScriptURL
|
15
|
+
get '/' do
|
16
|
+
return shop.result
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'pry_debug'
|
3
|
+
require_relative '../lib/aboutyou-sdk.rb'
|
4
|
+
|
5
|
+
class AY
|
6
|
+
attr_accessor :result
|
7
|
+
|
8
|
+
def putsCatName(category)
|
9
|
+
category = Array(category)
|
10
|
+
self.result = self.result + '<ul>'
|
11
|
+
category.each do |cat|
|
12
|
+
self.result = self.result + ('<li>'+cat.name+'</li>')
|
13
|
+
if (cat.subCategories(true))
|
14
|
+
putsCatName(cat.subCategories(true))
|
15
|
+
else
|
16
|
+
puts ""
|
17
|
+
end
|
18
|
+
end
|
19
|
+
self.result = self.result + '</ul>'
|
20
|
+
return result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
shop = AY.new(281, 'e6068c4ca020262613d06122663cb300')
|
25
|
+
shop.result = ""
|
26
|
+
|
27
|
+
productsResult = shop.fetchProductsByEans(["7323000051968"], ["variants", "default_image"])
|
28
|
+
productsResult.products.each do |prod|
|
29
|
+
shop.result = shop.result + '<ul>' + '<li>' + String(prod.id) + ' : ' + prod.name + '</br>' + '<img src="' + prod.defaultImage.url + '">'
|
30
|
+
prod.variants.each_with_index do |var, index|
|
31
|
+
shop.result = shop.result + '<ul>' + '<li>' + 'Variante: '+ String(index) + String(var.id) + '</ul>'
|
32
|
+
end
|
33
|
+
shop.result = shop.result + '</li>' + '</ul>'
|
34
|
+
end
|
35
|
+
get "/" do
|
36
|
+
return shop.result
|
37
|
+
end
|
data/tests/testProductsByIds.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'sinatra'
|
2
|
-
|
3
|
-
require 'aboutyou-sdk.rb'
|
2
|
+
require_relative '../AboutYou.rb'
|
4
3
|
|
5
4
|
class AY
|
6
5
|
attr_accessor :result
|
@@ -24,10 +23,13 @@ end
|
|
24
23
|
shop = AY.new(281, 'e6068c4ca020262613d06122663cb300')
|
25
24
|
shop.result = ""
|
26
25
|
|
27
|
-
productsResult = shop.fetchProductsByIds([661132],
|
28
|
-
binding.pry
|
26
|
+
productsResult = shop.fetchProductsByIds([661132, 660971, 661367, 661361, 661350, 661345],["default_image", "variants"])
|
29
27
|
productsResult.products.each do |prod|
|
30
|
-
shop.result = shop.result + prod.
|
28
|
+
shop.result = shop.result + '<ul>' + '<li>' + String(prod.id) + ' : ' + prod.name + '</br>' + '<img src="' + prod.defaultImage.url + '">'
|
29
|
+
prod.variants.each_with_index do |var, index|
|
30
|
+
shop.result = shop.result + '<ul>' + '<li>' + 'Variante: '+ String(index) + String(var.id) + '</ul>'
|
31
|
+
end
|
32
|
+
shop.result = shop.result + '</li>' + '</ul>'
|
31
33
|
end
|
32
34
|
get "/" do
|
33
35
|
return shop.result
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'pry_debug'
|
3
|
+
require_relative '../lib/aboutyou-sdk.rb'
|
4
|
+
|
5
|
+
class AY
|
6
|
+
attr_accessor :result
|
7
|
+
|
8
|
+
def putsCatName(category)
|
9
|
+
category = Array(category)
|
10
|
+
self.result = self.result + '<ul>'
|
11
|
+
category.each do |cat|
|
12
|
+
self.result = self.result + ('<li>'+cat.name+'</li>')
|
13
|
+
if (cat.subCategories(true))
|
14
|
+
putsCatName(cat.subCategories(true))
|
15
|
+
else
|
16
|
+
puts ""
|
17
|
+
end
|
18
|
+
end
|
19
|
+
self.result = self.result + '</ul>'
|
20
|
+
return result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
shop = AY.new(281, 'e6068c4ca020262613d06122663cb300')
|
25
|
+
|
26
|
+
get "/" do
|
27
|
+
shop.result = ""
|
28
|
+
suggestResult = shop.fetchSuggest("Hose")
|
29
|
+
suggestResult.each do |suggest|
|
30
|
+
shop.result = shop.result + suggest + '</br>'
|
31
|
+
end
|
32
|
+
return shop.result
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aboutyou-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferenc Beutel
|
@@ -104,12 +104,17 @@ files:
|
|
104
104
|
- tests/testAutocomplete.rb
|
105
105
|
- tests/testCatFilter.rb
|
106
106
|
- tests/testCatTree.rb
|
107
|
+
- tests/testFacetTypes.rb
|
107
108
|
- tests/testFacets.rb
|
109
|
+
- tests/testFetchFacet.rb
|
110
|
+
- tests/testJavaScript.rb
|
108
111
|
- tests/testProdCatLongestPath.rb
|
109
112
|
- tests/testProductSearchResult.rb
|
113
|
+
- tests/testProductsByEans.rb
|
110
114
|
- tests/testProductsByIds.rb
|
115
|
+
- tests/testSuggest.rb
|
111
116
|
- tests/testVariantsByIds.rb
|
112
|
-
homepage:
|
117
|
+
homepage: https://developer.aboutyou.de
|
113
118
|
licenses:
|
114
119
|
- MIT
|
115
120
|
metadata: {}
|