diff --git a/src/main/java/com/smartystreets/api/us_extract/Client.java b/src/main/java/com/smartystreets/api/us_extract/Client.java index b683e15..27b1222 100644 --- a/src/main/java/com/smartystreets/api/us_extract/Client.java +++ b/src/main/java/com/smartystreets/api/us_extract/Client.java @@ -42,6 +42,7 @@ private Request buildRequest(Lookup lookup) { request.putParameter("aggressive", String.valueOf(lookup.isAggressive())); request.putParameter("addr_line_breaks", String.valueOf(lookup.addressesHaveLineBreaks())); request.putParameter("addr_per_line", String.valueOf(lookup.getAddressesPerLine())); + request.putParameter("match", lookup.getMatch()); return request; } diff --git a/src/main/java/com/smartystreets/api/us_extract/Lookup.java b/src/main/java/com/smartystreets/api/us_extract/Lookup.java index e10f900..b0ec3b2 100644 --- a/src/main/java/com/smartystreets/api/us_extract/Lookup.java +++ b/src/main/java/com/smartystreets/api/us_extract/Lookup.java @@ -1,5 +1,8 @@ package com.smartystreets.api.us_extract; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.smartystreets.api.us_street.MatchType; + /** * In addition to holding all of the input data for this lookup, this class also
* will contain the result of the lookup after it comes back from the API. @@ -15,6 +18,8 @@ public class Lookup { private int addressesPerLine; private String text; + private String match; + //endregion public Lookup() { @@ -56,6 +61,21 @@ public String getText() { return text; } + @JsonProperty("match") + public String getMatch() { + if (this.match == null) + return null; + if (this.match.equals("strict") ) + return "strict"; + if (this.match.equals("range") ) + return "range"; + if (this.match.equals("invalid") ) + return "invalid"; + if (this.match.equals("enhanced") ) + return "enhanced"; + return null; + } + //endregion //region [ Setters ] @@ -84,5 +104,9 @@ public void setText(String text) { this.text = text; } + public void setMatch(MatchType match) { + this.match = match.getName(); + } + //endregion } diff --git a/src/main/java/examples/UsExtractExample.java b/src/main/java/examples/UsExtractExample.java index 477a4d5..5a99f99 100644 --- a/src/main/java/examples/UsExtractExample.java +++ b/src/main/java/examples/UsExtractExample.java @@ -6,8 +6,10 @@ import com.smartystreets.api.exceptions.SmartyException; import com.smartystreets.api.us_extract.*; import com.smartystreets.api.us_street.Candidate; +import com.smartystreets.api.us_street.MatchType; import java.io.IOException; +import java.util.Arrays; public class UsExtractExample { public static void main(String[] args) { @@ -18,10 +20,11 @@ public static void main(String[] args) { // for client-side requests (browser/mobile), use this code: SharedCredentials credentials = new SharedCredentials(System.getenv("SMARTY_AUTH_WEB"), System.getenv("SMARTY_AUTH_REFERER")); - Client client = new ClientBuilder(credentials).buildUsExtractApiClient(); + Client client = new ClientBuilder(credentials).withLicenses(Arrays.asList("us-core-cloud")).buildUsExtractApiClient(); String text = "Here is some text.\r\nMy address is 3785 Las Vegs Av." + "\r\nLos Vegas, Nevada." + - "\r\nMeet me at 1 Rosedale Baltimore Maryland, not at 123 Phony Street, Boise Idaho."; + "\r\nMeet me at 1 Rosedale Baltimore Maryland, not at 123 Phony Street, Boise Idaho." + + "\r\n808 County Road 408 Brady, Tx."; // Documentation for input fields can be found at: // https://smartystreets.com/docs/cloud/us-extract-api#http-request-input-fields @@ -30,6 +33,7 @@ public static void main(String[] args) { lookup.isAggressive(true); lookup.addressesHaveLineBreaks(); lookup.getAddressesPerLine(); + lookup.setMatch(MatchType.ENHANCED); try { Result result = client.send(lookup); @@ -51,6 +55,7 @@ public static void main(String[] args) { for (Candidate candidate : address.getCandidates()) { System.out.println(candidate.getDeliveryLine1()); System.out.println(candidate.getLastLine()); + System.out.println(candidate.getAnalysis().getEnhancedMatch()); System.out.println(); } } else System.out.println();