smartystreets / smartystreets-ruby-sdk Goto Github PK
View Code? Open in Web Editor NEWThe official client libraries for accessing SmartyStreets APIs from Ruby
Home Page: https://smartystreets.com/docs/sdk/ruby
License: Apache License 2.0
The official client libraries for accessing SmartyStreets APIs from Ruby
Home Page: https://smartystreets.com/docs/sdk/ruby
License: Apache License 2.0
Hello,
I'm using this SDK to tap into the US Autocomplete Pro API
While results are being returned, I noticed that none of them include the zip code as described in the documentation
My Lookup
object is set up per the basic example:
Lookup.new("3708 W Wrightwood Ave, 60647", 10)
Is there an option I'm missing here?
Thanks in advance for any leads :)
Was getting the below error message when running tests.
NoMethodError:
undefined method `<' for nil:NilClass
# ~.../smartystreets_ruby_sdk/retry_sender.rb:17:in `block in send'
Line that is breaking:
break if response.status_code < STATUS_INTERNAL_SERVER_ERROR
Looks like response is nil in this case.
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', []))
International Autocomplete API is returning 3 characters postal_code
for Canada. While Canada postal code consist of six characters. It look like its missing last 3 characters. Please find my request and response JSON below
{
"parameters": {
"search": "115 Strachan St",
"country": "CAN",
"license": "international-autocomplete-cloud",
"auth-id": "AUTH-ID",
"auth-token": "AUTH_TOKEN"
},
"payload": null,
"url_prefix": "https://international-autocomplete.api.smartystreets.com/lookup",
"referer": null,
"headers": {
},
"content_type": "application/json"
}
{
"candidates": [
{
"street": "115 Strachan St",
"locality": "Stratford",
"administrative_area": "ON",
"postal_code": "N5A",
"country_iso3": "CAN"
},
{
"street": "115 Strachan St",
"locality": "Richmond",
"administrative_area": "ON",
"postal_code": "K0A",
"country_iso3": "CAN"
},
{
"street": "115 Strachan St",
"locality": "Port Hope",
"administrative_area": "ON",
"postal_code": "L1A",
"country_iso3": "CAN"
},
{
"street": "115 Strachan St E",
"locality": "Hamilton",
"administrative_area": "ON",
"postal_code": "L8L",
"country_iso3": "CAN"
}
]
}
Not: This isn't smartystreets-ruby-sdk
gem issue rather smarty street API issue.
This appears to be a 2.0 regression in CoreClientBuilder's initializer.
Stack trace:
File "/app/vendor/bundle/ruby/2.2.0/gems/smartystreets_ruby_sdk-5.0.0/lib/smartystreets_ruby_sdk/international_street/client.rb" line 50 in convert_candidates
File "/app/vendor/bundle/ruby/2.2.0/gems/smartystreets_ruby_sdk-5.0.0/lib/smartystreets_ruby_sdk/international_street/client.rb" line 20 in send
The issue is probably in all clients, in convert_candidates
:
https://github.com/smartystreets/smartystreets-ruby-sdk/blob/master/lib/smartystreets_ruby_sdk/international_street/client.rb#L50
And will happen for any failure because as the payload is set to nil
here as deserializing nil
will result in the value of nil
here as:
> JSON.load(nil)
=> nil
Is there a practical reason for custom request headers to be logged to stdout
? Looking at this diff it looks like they were added for debugging reasons. This causes a lot of unnecessary logging when Smarty Streets is added to a larger application and stubbed in the test suite.
Due to this line (from this commit for context) it's impossible to set your candidates to 1 while using enhanced matching.
It looks like the intention of the line is to set candidates to 5
if you're using enhanced matching and are using the default option for candidates in lookups (which is also 1) but there are cases in which you would legitimately want 1 candidate with enhanced matching.
It seems like the value passed in to the client builder falls right through to Net::HTTP
, which interprets that number in seconds:
That makes the default timeout over two hours ๐ฌ
Hi SmartyStreets devs,
I'm looking at upgrading from 5.5.4 to the 5.6.0 version of the SmartyStreets ruby SDK. However, this looks like a breaking change:
In SmartyStreets::RetrySender
there's the method:
def backoff(attempt)
backoff_duration = [attempt, MAX_BACKOFF_DURATION].min
@logger.warn("There was an error processing the request. Retrying in #{backoff_duration} seconds...")
@sleeper.sleep(backoff_duration)
end
However, the default SmartyStreets::Logger
doesn't define a :warn
method:
module SmartyStreets
class Logger
def log(message)
puts message
end
end
end
During my tests, this gives: #<NoMethodError: private method 'warn' called for #<SmartyStreets::Logger:0x00007fe64d17b6d8>>
When I swap out warn
for log
, everything works fine.
Thank you for investigating.
I'm including the gem in a rails app. I can use all of the classes except SmartyStreets::InternationalStreet::Lookup.
All of this code works perfectly.
credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
client = SmartyStreets::ClientBuilder.new(credentials).build_us_zipcode_api_client
lookup = SmartyStreets::USZipcode::Lookup.new
and also
client = SmartyStreets::ClientBuilder.new(credentials).build_international_street_api_client
But, when I call lookup = SmartyStreets::InternationalStreet::Lookup.new("A0A 0A2", 'Canada')
I get the error message:
NameError: uninitialized constant SmartyStreets::InternationalStreet::Lookup
I found that if I manually require that file first, it will work. But not without requiring it first.
require 'smartystreets_ruby_sdk/international_street/lookup'
Both US Street Client and International Street Client are very similar when it comes to usage.
I thought it was a bit confusing that both of them provide a method aimed to send lookup, however the first one defines it as send_lookup(lookup)
while the other one defines it as send(lookup)
.
Specially when it comes to the international street client, it also feels weird to call client.send(lookup)
. For someone who's not familiar with the gem, by doing it like this, it gives the impression that we're trying to call a private method name lookup
(using the native Object#send) and forgot to use the :
to specify lookup
as symbol
Would it make sense to rename it to send_lookup
, to avoid confusion in both scenarios?
If positive, I would be happy to help with this change.
The minor version was updated, but it seems to me that the change on is_ews_match
changed the field from a boolean to a string since it now is a deprecation warning.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.