Giter VIP home page Giter VIP logo

smartystreets-java-sdk's People

Contributors

alrwarner avatar andrewjohnsonsmarty avatar blacelle avatar carolinehickey avatar ckholt83 avatar dependabot[bot] avatar duncanbeutler avatar dwhatcott avatar eduard-romaniuk avatar jcrob2 avatar jwnacnud avatar landonsmarty avatar listaction avatar mdwhatcott avatar mouaying avatar oshionniemela avatar rripley avatar ryanlcox1 avatar savannah-ryan avatar smartybryan avatar smartycaroine avatar xansmarty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smartystreets-java-sdk's Issues

ClientBuilder doesn't pass along connection settings to OkHttpClient

I tried doing this:

this.client = new ClientBuilder(new StaticCredentials(authId, authToken))
        .withLicenses(license.getLicenses())
        .withMaxTimeout(timeoutSeconds * 1000)
        .buildUsStreetApiClient();

and variations of this, but couldn't get it to work. Then I realized that your ClientBuilder.buildUsStreetApiClient() calls SmartySender(int maxTimeout) constructor.

The maxTimeout is ignored and this constructor should be something like this:

public SmartySender(int maxTimeout) {
    this.maxTimeOut = maxTimeout;
    this.client = new OkHttpClient.Builder()
                .writeTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS)
                .readTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS)
                .connectTimeout(this.maxTimeOut, TimeUnit.MILLISECONDS)
                .build();
}

Are you guys open to PRs from community?

Smarty street is failing to validate valid US addresses

For example I have tried below Valid US addresses.

Below address is valid but I am getting invalid address in response.
`

  lookup.setStreet("Hartford Street");

  lookup.setCity("San Francisco");

  lookup.setState("CA");

  lookup.setZipCode("94114");`

And
Wrong City is being returned by the API i.e. Alameda. Also, City is being returned in Country.

`

 lookup.setCity("Pleasanton");

 lookup.setStreet("5776 Stoneridge Mall Road");

 lookup.setState("CA");

 lookup.setZipCode("94588");`

I have tried with
com.smartystreets.api:smartystreets-java-sdk:2.1.2
and
com.smartystreets.api:smartystreets-java-sdk:3.2.0

NullPointerException in us_street.Client.send method

I keep getting this error:

java.lang.NullPointerException
	at com.smartystreets.api.us_street.Client.send(Client.java:51)

I'm still struggling to get more details because it happens in a cloud environment, and the exception doesn't provide much help. What I've managed to figure out is that this.sender.send(request) returns null. This suggests that one of the senders in the chain is returning null, and Client doesn't have any logic to handle it.

It's worth mentioning that the problem occurs in some cases, but not all. Most of the addresses are normalized just fine.

The Smarty SDK version I'm using is 3.16.1. The normalization occurs as a part of an Apache Beam pipeline, executed in Dataflow.

Release Notes

Hello Smartystreets team,
Thank you for updating your java sdk, my company currently uses it in our Sendwave app and it works great.

I was wondering, where can one get release notes for the latest update? We tend to attach these notes to PR's when we update our libraries.

how can we verify a candidate from the client?

hello folks,
say we have client side integration that gets the address via client side calls, how can one verify (the candidate) client sends to our service is valid?

  1. Does the initial response from smarty contain some type of a hash?
  2. How can one map, Candidate to Lookup if the above is missing (best practice that works for US Street Addresses)?

java.lang.NoClassDefFoundError: java/net/http/HttpClient

I am having this issue when trying to run some tests.

java.lang.NoClassDefFoundError: java/net/http/HttpClient
at com.smartystreets.api.GoogleSender.(GoogleSender.java:24)

Isnt java.net.http.HttpClient from Java 11?
That will render your API not compatible with versions prior to 11.

Bulk zipcode lookup: Cannot invoke "com.smartystreets.api.Response.getPayload()" because "response" is null

If I construct a batch query to the UsZipCode API using the SS Java SDK as follows:

        String authId = System.getenv("ss.authId");
        String authToken = System.getenv("ss.authToken");
        Credentials creds = new StaticCredentials(authId, authToken);
        Client client = new ClientBuilder(creds).buildUsZipCodeApiClient();
        Batch batch = new Batch();
        try {
            batch.add(new Lookup("92093"));
            batch.add(new Lookup("87714"));
            client.send(batch);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

This results in:

java.lang.NullPointerException: Cannot invoke "com.smartystreets.api.Response.getPayload()" because "response" is null
	at com.smartystreets.api.us_zipcode.Client.send(Client.java:49)

Digging into the SDK code, I see that the server is returning HTTP 415. This is because the SDK by default is not passing a content-type header with the request.

I can work around this by constructing my client with a custom header of "Content-type: application/json" as follows:

        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-type", "application/json");
        Client client = new ClientBuilder(creds).withCustomHeaders(headers).buildUsZipCodeApiClient();

But shouldn't this header be aded automatically in the SDK client code? I can't pass any other value for the content type other than "application/json" since JSON what the SDK client sends.

Breaking changes on Android with Java SDK

Hi,

The changes in 3.11.0 "Moved to Java 11 to support HTTP Client. This is a breaking change for anyone using earlier versions of Java", has prevented Android users from importing the smartystreets-java-sdk from maven. Android/Google only provides a subset of features in Java 11. One of them is not java.net.http.HttpClient. Therefore, when we try to instantiate a client with ClientBuilder, we get

Caused by: java.lang.ClassNotFoundException: Didn't find class "java.net.http.HttpClient" on path: DexPathList.

I could go back to the previous version of 3.10.7 which uses com.google.api.client.http, but the issue with that is, my product manager has asked that we set the source to "postal" to eliminate P.O box results, and that option was not added to US Autocomplete Pro lookup until 3.11.0. We are currently in the evaluation process, and my PM has not purchased a license yet, but if I can't find a way to import java.net.http.HttpClient into our Android project, then this catch-22 with java.net.http.HttpClient/source field availability, may force us to have to go with Google Places. So, I wanted to ask what you would recommend? Hopefully, we can receive an answer asap, as my requirements are to finish the address search feature this sprint.
Thank you in advance.

Here is a link showing what java.net classes are available on Android:
https://developer.android.com/reference/java/net/package-summary

Unfortunately, importing java.net.http as a library is not a viable option. See some of the reasons here in this StackOverFlow:
https://stackoverflow.com/questions/69750452/how-can-i-use-jdk-11-http-packages-in-android

commons-logging defines classes that conflict with classes now provided by Android

/home/********/********/app/build.gradle: Error: commons-logging defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
/home/********/********/app/build.gradle: Error: httpclient defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]

You should make a note when this is being included with an Android project to exclude those. Thanks!

NoClassDefFoundError on latest

Following the getting started documentation, on latest builds, I get the following error on JDK 8:

java.lang.NoClassDefFoundError: java/net/http/HttpClient
	at com.smartystreets.api.GoogleSender.<init>(GoogleSender.java:24)

I believe the java.net.http.HttpClient is only available in JDK 11+? But documentation says Java SDK (targets Java 7 or above) and under requirements Download and install Java 7 or higher. Am I missing something?

Retry wait time after TooManyRequestsResponse hardcoded to 10

In the RetrySender.send method the client sleeps for 10 seconds when a TooManyRequestsResponse is received. As far as I know SmartyStreets rate limits are based on requests per second, so this wait time seems excessive. It would be ideal if this value was configurable via the ClientBuilder like the maxRetries used in this class or if it used an incremental backoff like in the RetrySender.trySend method.

The hardcoded wait time section:

public Response send(Request request) throws SmartyException, IOException, InterruptedException {
        for(int i = 0; i <= this.maxRetries; ++i) {
            Response response = this.trySend(request, i);
            if (response instanceof TooManyRequestsResponse) {
                long wait = 10L;
...

Gradle doesn't build on latest version

My issue was not being able to import the latest version (3.4.0) into my Android app. I currently use the version 3.3.8 and it doesn't work, but when I upgrade to 3.4.0, gradle fails to build with error ERROR: Failed to resolve: com.smartystreets.api:smartystreets-java-sdk:3.4.0.

I'm importing this as;

implementation 'com.smartystreets.api:smartystreets-java-sdk:3.4.0'

That's based on the Maven import structure.

This also doesn't work

implementation 'com.github.smartystreets:smartystreets-java-sdk:3.4.0'

Which is based on the structure of the old version which works.

Authorization header throwing exceptions (withCustomHeaders)

Thank you for including custom headers in the new 3.3.0 release.

I noticed an issue if I use the Authorization custom header(s) with this package:

val url = "api-gateway-test/smartystreets/street-address"
val customHeaders = new HashMap[String, String]()
val bearerToken = "test123" 
customHeaders.put("Authorization", s"Bearer ${bearerToken}")

val client = new ClientBuilder(credentials)
          .withCustomBaseUrl(url)
          .withCustomHeaders(customHeaders)
          .buildUsStreetApiClient()

val lookup = new Lookup();
lookup.setStreet("1600 Amphitheatre Pkwy");
lookup.setCity("Mountain View");
lookup.setState("CA");
batch.add(lookup);
client.send(batch);

Exception: java.lang.IllegalArgumentException: Can not set java.util.List field com.google.api.client.http.HttpHeaders.authorization to java.lang.String.

Any thoughts on how I would pass custom Authorization headers to the client?

Thanks for your time.

Marko Vujovic

[Bug] Batch request doesn't work as expected

Hi,

I've noticed that when I'm making a batch request, some lookups aren't getting any results. But when I make a single request per single problematic lookup, it gets me a result just fine (screenshots attached).

Smarty Client init:

    Credentials credentials = new StaticCredentials(smartyProperties.getAuthId(), smartyProperties.getAuthToken());

    Client client = new ClientBuilder(credentials).withLicenses(List.of(smartyProperties.getLicense()))
        .buildUsStreetApiClient();

License is us-core-enterprise-cloud

Batch after the request:
Batch request

First lookup after I made an exclusive request for it:
Single request for the first batch lookup

Second lookup after I made an exclusive request for it:
Single request for the second batch lookup

question on structured response and bindings

Hi Team,

amazing work on the api / service - more of a question / issue - depending on how you look at it .

When an API is called for an address, I get back something like below. Wondering if there is a standard binding in Java that ties all these things together (I looked briefly - but could not find it). I am looking for an object (DTO / Domain) object that has all these things - so that I don't have to recreate it.


  {
    "input_index": 0,
    "candidate_index": 0,
    "delivery_line_1": "200 Wachesaw Dr",
    "last_line": "Piedmont SC 29673-6409",
    "delivery_point_barcode": "296736409004",
    "components": {
      "primary_number": "200",
      "street_name": "Wachesaw",
      "street_suffix": "Dr",
      "city_name": "Piedmont",
      "default_city_name": "Piedmont",
      "state_abbreviation": "SC",
      "zipcode": "29673",
      "plus4_code": "6409",
      "delivery_point": "00",
      "delivery_point_check_digit": "4"
    },
    "metadata": {
      "record_type": "S",
      "zip_type": "Standard",
      "county_fips": "45007",
      "county_name": "Anderson",
      "carrier_route": "R016",
      "congressional_district": "03",
      "rdi": "Residential",
      "elot_sequence": "0080",
      "elot_sort": "A",
      "latitude": 34.78051,
      "longitude": -82.47835,
      "precision": "Zip8",
      "time_zone": "Eastern",
      "utc_offset": -5,
      "dst": true
    },
    "analysis": {
      "dpv_match_code": "Y",
      "dpv_footnotes": "AABB",
      "dpv_cmra": "N",
      "dpv_vacant": "N",
      "dpv_no_stat": "N",
      "active": "Y"
    }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.