Skip to content

Commit

Permalink
Fixed bug where us_street Client wasn't adding the match field to the…
Browse files Browse the repository at this point in the history
… query string when sending via GET.
  • Loading branch information
MouaYing committed Mar 30, 2018
1 parent 0529c18 commit 0d77e50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/com/smartystreets/api/us_street/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private void populateQueryString(Lookup address, Request request) {
request.putParameter("lastline", address.getLastline());
request.putParameter("addressee", address.getAddressee());
request.putParameter("urbanization", address.getUrbanization());
request.putParameter("match", address.getMatchString());

if (address.getMaxCandidates() != 1)
request.putParameter("candidates", Integer.toString(address.getMaxCandidates()));
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/smartystreets/api/us_street/Lookup.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public String getUrbanization() {
}

public MatchType getMatch() {
if (this.match == null)
return null;
if (this.match.equals("strict") )
return MatchType.STRICT;
if (this.match.equals("range") )
Expand All @@ -137,6 +139,13 @@ public MatchType getMatch() {
return null;
}

public String getMatchString() {
MatchType match = getMatch();
if (match != null)
return match.getName();
return null;
}

public int getMaxCandidates() {
return this.maxCandidates;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testSendingSingleFullyPopulatedLookup() throws Exception {

assertEquals("http://localhost/?street=1&street2=3" +
"&secondary=2&city=5&state=6&zipcode=7&lastline=8&addressee=0" +
"&urbanization=4&candidates=9", capturingSender.getRequest().getUrl());
"&urbanization=4&match=invalid&candidates=9", capturingSender.getRequest().getUrl());

}

Expand Down

0 comments on commit 0d77e50

Please sign in to comment.