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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2Q0MGRiOTIwZTM2OGQwYWM5MzA5NmIzYzhhNGRhY2IyZGU1MGQyZg==
4
+ YjFiOTBiOTIxNjQxMTM1ZDdkMzQ4NTU5YzA3MDU5YmRiMGY2MGUzZg==
5
5
  data.tar.gz: !binary |-
6
- M2Y0ZmYwMDEwOTcxNDYwMWYwNmViZGFmMGVhZGEyZTY0YzRlNWU3Zg==
6
+ YmM2MjIwOTg0ZGY0MjViYmYxNDY4NmNhYzM0MWYwY2MzMjU1MjM0Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTYyMTY0YmRkODQ5NmNlNTYwZDRlNjIxOThlMTM2MGE1M2VhNmY5YTE4NDQw
10
- NzRlNDA3ZjY2NjE1YjMxZGVjZDU4YTVmMmQ5NDdjYTUyNTFhNDMzOTU3Y2Rh
11
- MDcyNWVlOTFkNzFjZGIwMDc3NzAzZDI2MTA3MDM2YTFlODNlOGM=
9
+ NzY1MDBiM2NkZWRmM2IzNzE0NTBkZTlkYzI2YjdlMGZhYjg1ZWFiODM3MjYw
10
+ ODc2MDg3M2I1NTdkYzFiY2Q1MmU3NzdiNzI1NDE5NDJjZmE2OThmMjVkOThi
11
+ OGZhODViMWEzM2I2YzU2ODdmMzQyZTZiOTZlMTEzYjQ3ZDBjOTY=
12
12
  data.tar.gz: !binary |-
13
- N2RmYzYzNmUwMDA3NDM2ZDU1ZWQzY2ZjNTMwYmUxNDYwZTFiMjFkNDE1N2Vk
14
- Zjg0ZGMzOTc0NzQ0NjgxODY4OTg5NDgwYTQ0Y2FlOWIxMmVmOGQwMDRkNjU2
15
- NTU5MzIyMjAwMDA3NDk1ZDViZDZkMjZmNjE1OTYyMzI5ZDBlZWE=
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
  #
@@ -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
@@ -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?(Long)
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.
@@ -50,4 +50,7 @@ get "/blogTest" do
50
50
  end
51
51
  get "/filterByFacetIds" do
52
52
  erb :docExampleFilterByFacetIds
53
+ end
54
+ get "/docExampleSpellCorrection" do
55
+ erb :testDocExampleSpellCorrection
53
56
  end
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  get "/doCache" do
5
5
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Dalli.new(Dalli::Client.new))
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  get "/doCache" do
5
5
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Dalli.new(Dalli::Client.new))
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative'../lib/ay.rb'
2
+ require_relative'../lib/aboutyou-sdk.rb'
3
3
 
4
4
  get "/doCache" do
5
5
  shop = AY.new(281, 'e6068c4ca020262613d06122663cb300', 'sessionId', AboutYou::SDK::CacheProvider::Redis.new(Redis.new))
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
@@ -1,5 +1,5 @@
1
1
  require 'sinatra'
2
- require_relative '../lib/ay.rb'
2
+ require_relative '../lib/aboutyou-sdk.rb'
3
3
 
4
4
  class AY
5
5
  attr_accessor :result
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.27
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferenc Beutel