aboutyou-sdk 0.0.27 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/AboutYou/Factory/default_model_factory.rb +13 -0
- data/lib/AboutYou/query.rb +2 -1
- data/lib/AboutYou/query_builder.rb +28 -0
- data/lib/aboutyou-sdk.rb +29 -1
- data/tests/Sinatra-test/Main.rb +3 -0
- data/tests/testAutocomplete.rb +1 -1
- data/tests/testCatFilter.rb +1 -1
- data/tests/testCatTree.rb +1 -1
- data/tests/testCategoryCaching.rb +1 -1
- data/tests/testDalliCache.rb +1 -1
- data/tests/testFacetTypes.rb +1 -1
- data/tests/testFacets.rb +1 -1
- data/tests/testFetchFacet.rb +1 -1
- data/tests/testJavaScript.rb +1 -1
- data/tests/testProdCatLongestPath.rb +1 -1
- data/tests/testProductSearchResult.rb +1 -1
- data/tests/testProductsByEans.rb +1 -1
- data/tests/testProductsByIds.rb +1 -1
- data/tests/testRedisCache.rb +1 -1
- data/tests/testSuggest.rb +1 -1
- data/tests/testVariantsByIds.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjFiOTBiOTIxNjQxMTM1ZDdkMzQ4NTU5YzA3MDU5YmRiMGY2MGUzZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmM2MjIwOTg0ZGY0MjViYmYxNDY4NmNhYzM0MWYwY2MzMjU1MjM0Ng==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzY1MDBiM2NkZWRmM2IzNzE0NTBkZTlkYzI2YjdlMGZhYjg1ZWFiODM3MjYw
|
10
|
+
ODc2MDg3M2I1NTdkYzFiY2Q1MmU3NzdiNzI1NDE5NDJjZmE2OThmMjVkOThi
|
11
|
+
OGZhODViMWEzM2I2YzU2ODdmMzQyZTZiOTZlMTEzYjQ3ZDBjOTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGM2MDFjNjAzZTU5MmI1ZDc2NzFlYTA4ZjFlMDliZTAxYmU2NzQ1ODZmNTdi
|
14
|
+
NGRjODIwOGJjMjVjMDZhN2Y2ZmZlNzA2ZjkyMGE2NDRjNzRkMzUwOGE4MTI3
|
15
|
+
MDMyYTM2MDI0MTEyMGQ3NTg2ZDdlYWQ0NjBhODkwY2EyN2NlZGU=
|
@@ -543,6 +543,19 @@ module AboutYou
|
|
543
543
|
AboutYou::SDK::Model::App.create_from_json(json_object)
|
544
544
|
end
|
545
545
|
|
546
|
+
###
|
547
|
+
# creates an spell correction result
|
548
|
+
#
|
549
|
+
# * *Args* :
|
550
|
+
# - +json_array+ -> the api response in an array
|
551
|
+
#
|
552
|
+
# * *Returns* :
|
553
|
+
# - an Array containing String
|
554
|
+
###
|
555
|
+
def create_spell_correction(json_array, _query)
|
556
|
+
json_array
|
557
|
+
end
|
558
|
+
|
546
559
|
###
|
547
560
|
# this methods initiates the category manager
|
548
561
|
#
|
data/lib/AboutYou/query.rb
CHANGED
@@ -60,7 +60,8 @@ module AboutYou
|
|
60
60
|
'get_order' => 'create_order',
|
61
61
|
'initiate_order' => 'initiate_order',
|
62
62
|
'child_apps' => 'create_child_apps',
|
63
|
-
'live_variant' => 'create_variants_result'
|
63
|
+
'live_variant' => 'create_variants_result',
|
64
|
+
'did_you_mean' => 'create_spell_correction'
|
64
65
|
}
|
65
66
|
end
|
66
67
|
|
@@ -490,6 +490,34 @@ module AboutYou
|
|
490
490
|
|
491
491
|
self
|
492
492
|
end
|
493
|
+
|
494
|
+
###
|
495
|
+
# builds the spell_correction
|
496
|
+
#
|
497
|
+
# * *Args* :
|
498
|
+
# - +searchword+ -> the search string to search for
|
499
|
+
# - +category_ids+ -> the cat ids to filter for
|
500
|
+
#
|
501
|
+
# * *Returns* :
|
502
|
+
# - Instance of AboutYou::SDK::Query
|
503
|
+
###
|
504
|
+
def fetch_spell_correction(searchword, category_ids = nil)
|
505
|
+
fail 'InvalidArgumentException! searchword must be a string' unless
|
506
|
+
searchword.is_a?(String)
|
507
|
+
|
508
|
+
options = {
|
509
|
+
'searchword' => searchword
|
510
|
+
}
|
511
|
+
options['filter'] = {
|
512
|
+
'categories' => category_ids
|
513
|
+
} unless category_ids.empty?
|
514
|
+
|
515
|
+
query.push(
|
516
|
+
'did_you_mean' => options
|
517
|
+
)
|
518
|
+
|
519
|
+
self
|
520
|
+
end
|
493
521
|
|
494
522
|
###
|
495
523
|
# builds the child_apps-query
|
data/lib/aboutyou-sdk.rb
CHANGED
@@ -117,7 +117,7 @@ class AY
|
|
117
117
|
def add_item_to_basket(session_id, variant_id, amount = 1)
|
118
118
|
basket = AboutYou::SDK::Model::Basket.new
|
119
119
|
|
120
|
-
unless variant_id.is_a?(
|
120
|
+
unless variant_id.is_a?(Integer)
|
121
121
|
if variant_id.is_a?(String) && variant_id[/\d/]
|
122
122
|
variant_id = Integer(variant_id)
|
123
123
|
else
|
@@ -222,6 +222,34 @@ class AY
|
|
222
222
|
)
|
223
223
|
query.fetch_autocomplete(searchword, limit, types).execute_single
|
224
224
|
end
|
225
|
+
|
226
|
+
###
|
227
|
+
# Returns the result of an spell correction API request.
|
228
|
+
# spell correction searches for products by a given searchword.
|
229
|
+
# You might filter by category ids aswell.
|
230
|
+
#
|
231
|
+
# * *Args* :
|
232
|
+
# - +searchword+ -> The prefix search word to search for
|
233
|
+
# - +category_ids+ -> The category ids used as a filter [optional]
|
234
|
+
#
|
235
|
+
# * *Returns* :
|
236
|
+
# - Array of Strings
|
237
|
+
###
|
238
|
+
def fetch_spell_correction(searchword, category_ids = nil)
|
239
|
+
unless category_ids.nil?
|
240
|
+
# we allow to pass a single ID instead of an array
|
241
|
+
category_ids = Array(category_ids)
|
242
|
+
|
243
|
+
category_ids.each do |cat_id|
|
244
|
+
fail 'InvalidArgumentException! A single category ID must be an integer
|
245
|
+
or a numeric string' unless cat_id.is_a?(Integer) || cat_id[/\d/]
|
246
|
+
fail '\InvalidArgumentException! A single category ID must be greater
|
247
|
+
than 0' if cat_id < 1
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
query.fetch_spell_correction(searchword, category_ids).execute_single
|
252
|
+
end
|
225
253
|
|
226
254
|
###
|
227
255
|
# Fetch the basket of the given session_id.
|
data/tests/Sinatra-test/Main.rb
CHANGED
data/tests/testAutocomplete.rb
CHANGED
data/tests/testCatFilter.rb
CHANGED
data/tests/testCatTree.rb
CHANGED
data/tests/testDalliCache.rb
CHANGED
data/tests/testFacetTypes.rb
CHANGED
data/tests/testFacets.rb
CHANGED
data/tests/testFetchFacet.rb
CHANGED
data/tests/testJavaScript.rb
CHANGED
data/tests/testProductsByEans.rb
CHANGED
data/tests/testProductsByIds.rb
CHANGED
data/tests/testRedisCache.rb
CHANGED
data/tests/testSuggest.rb
CHANGED
data/tests/testVariantsByIds.rb
CHANGED