Skip to content

Commit

Permalink
MatchType is made lowercase on the payload.
Browse files Browse the repository at this point in the history
  • Loading branch information
DuncanBeutler committed May 3, 2022
1 parent 0ef7e5c commit b64f3e8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/smartystreets/api/us_street/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ 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());
request.putParameter("match", address.getMatch());

if (address.getMaxCandidates() == 1 && address.getMatch() == MatchType.ENHANCED)
if (address.getMaxCandidates() == 1 && address.getMatch() == "enhanced")
request.putParameter("candidates", "5");
else
request.putParameter("candidates", Integer.toString(address.getMaxCandidates()));
Expand Down
46 changes: 27 additions & 19 deletions src/main/java/com/smartystreets/api/us_street/Lookup.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.smartystreets.api.us_street;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -24,14 +26,14 @@ public class Lookup implements Serializable {
private String addressee;
private String urbanization;
private String match;
private int maxCandidates;
private int candidates;

//endregion

//region [ Constructors ]

public Lookup() {
this.maxCandidates = 1;
this.candidates = 1;
this.result = new ArrayList<>();
}

Expand All @@ -56,6 +58,7 @@ void addToResult(Candidate newCandidate) {

//region [ Getters ]

@JsonProperty("result")
public List<Candidate> getResult() {
return this.result;
}
Expand All @@ -64,69 +67,74 @@ public Candidate getResult(int index) {
return this.result.get(index);
}

@JsonProperty("input_id")
public String getInputId() {
return this.inputId;
}

@JsonProperty("street")
public String getStreet() {
return this.street;
}

@JsonProperty("street2")
public String getStreet2() {
return this.street2;
}

@JsonProperty("secondary")
public String getSecondary() {
return this.secondary;
}

@JsonProperty("city")
public String getCity() {
return this.city;
}

@JsonProperty("state")
public String getState() {
return this.state;
}

@JsonProperty("zipcode")
public String getZipCode() {
return this.zipCode;
}

@JsonProperty("lastline")
public String getLastline() {
return this.lastline;
}

@JsonProperty("addressee")
public String getAddressee() {
return this.addressee;
}

@JsonProperty("urbanization")
public String getUrbanization() {
return this.urbanization;
}

public MatchType getMatch() {
@JsonProperty("match")
public String getMatch() {
if (this.match == null)
return null;
if (this.match.equals("strict") )
return MatchType.STRICT;
return "strict";
if (this.match.equals("range") )
return MatchType.RANGE;
return "range";
if (this.match.equals("invalid") )
return MatchType.INVALID;
return "invalid";
if (this.match.equals("enhanced") )
return MatchType.ENHANCED;
return null;
}

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

@JsonProperty("candidates")
public int getMaxCandidates() {
return this.maxCandidates;
return this.candidates;
}

//endregion
Expand Down Expand Up @@ -197,12 +205,12 @@ public void setMatch(MatchType match) {

/**
* Sets the maximum number of valid addresses returned when the input is ambiguous.
* @param maxCandidates Defaults to 1. Must be an integer between 1 and 10, inclusive.
* @param candidates Defaults to 1. Must be an integer between 1 and 10, inclusive.
* @throws IllegalArgumentException
*/
public void setMaxCandidates(int maxCandidates) throws IllegalArgumentException {
if (maxCandidates > 0) {
this.maxCandidates = maxCandidates;
public void setMaxCandidates(int candidates) throws IllegalArgumentException {
if (candidates > 0) {
this.candidates = candidates;
} else {
throw new IllegalArgumentException("Max candidates must be a positive integer.");
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/smartystreets/api/us_street/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Metadata implements Serializable {
private String elotSort;
private double latitude;
private double longitude;
private int coordinateLicense;
private String precision;
private String timeZone;
private double utcOffset;
Expand Down Expand Up @@ -92,6 +93,9 @@ public double getLongitude() {
return this.longitude;
}

@JsonProperty("coordinate_license")
public int getCoordinateLicense() { return this.coordinateLicense; }

@JsonProperty("precision")
public String getPrecision() {
return this.precision;
Expand Down

0 comments on commit b64f3e8

Please sign in to comment.