smartystreets / smartystreets-ruby-sdk

The official client libraries for accessing SmartyStreets APIs from Ruby
https://smartystreets.com/docs/sdk/ruby
Apache License 2.0
23 stars 25 forks source link

International Autocomplete Suggestion Bug #34

Closed wonderer007 closed 2 years ago

wonderer007 commented 2 years ago

I am trying to fetch suggestion for international address

Lookup = SmartyStreets::InternationalAutocomplete::Lookup

lookup = Lookup.new('Louis')
lookup.country = 'FRA'
lookup.locality = 'Paris'

suggestions = client.send(lookup)

And its breaking at

TypeError: no implicit conversion of String into Integer
from /smartystreets_ruby_sdk-5.14.0/lib/smartystreets_ruby_sdk/international_autocomplete/suggestion.rb:8:in `fetch'

The issue is in SmartyStreets::InternationalAutocomplete::Client when suggestion are built instead of object an Array being sent to InternationalAutocomplete::Suggestion which is wrong. Following update will fix the issue

At line https://github.com/smartystreets/smartystreets-ruby-sdk/blob/master/lib/smartystreets_ruby_sdk/international_autocomplete/client.rb#L27 update it with

suggestions = convert_suggestions(result.fetch('candidates', []))
DuncanBeutler commented 2 years ago

Updates to the SDK can found on version 5.14.8. Thanks for your contribution!