Skip to content

Commit

Permalink
Adds secondary dataset to enrichment api.
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanLCox1 committed Aug 22, 2024
1 parent f901881 commit 0854a20
Show file tree
Hide file tree
Showing 10 changed files with 481 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/main/java/com/smartystreets/api/us_enrichment/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
import com.smartystreets.api.us_enrichment.lookup_types.Lookup;
import com.smartystreets.api.us_enrichment.lookup_types.property_financial.PropertyFinancialLookup;
import com.smartystreets.api.us_enrichment.lookup_types.property_principal.PropertyPrincipalLookup;
import com.smartystreets.api.us_enrichment.lookup_types.secondary.SecondaryCountLookup;
import com.smartystreets.api.us_enrichment.lookup_types.secondary.SecondaryLookup;
import com.smartystreets.api.us_enrichment.result_types.property_financial.FinancialResponse;
import com.smartystreets.api.us_enrichment.result_types.property_principal.PrincipalResponse;
import com.smartystreets.api.us_enrichment.result_types.secondary.SecondaryCountResponse;
import com.smartystreets.api.us_enrichment.result_types.secondary.SecondaryResponse;

import java.io.IOException;

Expand All @@ -34,6 +38,18 @@ public PrincipalResponse[] sendPropertyPrincipalLookup(String smartyKey) throws
return lookup.getResults();
}

public SecondaryResponse[] sendSecondaryLookup(String smartKey) throws SmartyException, IOException, InterruptedException {
SecondaryLookup lookup = new SecondaryLookup(smartKey);
send(lookup);
return lookup.getResults();
}

public SecondaryCountResponse[] sendSecondaryCountLookup(String smartKey) throws SmartyException, IOException, InterruptedException {
SecondaryCountLookup lookup = new SecondaryCountLookup(smartKey);
send(lookup);
return lookup.getResults();
}

private void send(Lookup lookup) throws IOException, SmartyException, InterruptedException {
if (lookup == null || lookup.getSmartyKey() == null || lookup.getSmartyKey().isEmpty())
throw new SmartyException("Client.send() requires a Lookup with the 'smartyKey' field set");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.smartystreets.api.us_enrichment.lookup_types.secondary;

import com.smartystreets.api.Serializer;
import com.smartystreets.api.us_enrichment.lookup_types.Lookup;
import com.smartystreets.api.us_enrichment.result_types.secondary.SecondaryCountResponse;

import java.io.IOException;

public class SecondaryCountLookup extends Lookup {

private SecondaryCountResponse[] results;

public SecondaryCountLookup(String smartyKey) {
super(smartyKey, "secondary", "count");
}

public SecondaryCountResponse[] getResults() {
return results;
}

public void setResults(SecondaryCountResponse[] results) {
this.results = results;
}

@Override
public void deserializeAndSetResults(Serializer serializer, byte[] payload) throws IOException {
this.results = serializer.deserialize(payload, SecondaryCountResponse[].class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.smartystreets.api.us_enrichment.lookup_types.secondary;

import com.smartystreets.api.Serializer;
import com.smartystreets.api.us_enrichment.lookup_types.Lookup;
import com.smartystreets.api.us_enrichment.result_types.secondary.SecondaryResponse;

import java.io.IOException;

public class SecondaryLookup extends Lookup {

private SecondaryResponse[] results;

public SecondaryLookup(String smartyKey) {
super(smartyKey, "secondary", "");
}

public SecondaryResponse[] getResults() {
return results;
}

public void setResults(SecondaryResponse[] results) {
this.results = results;
}

@Override
public void deserializeAndSetResults(Serializer serializer, byte[] payload) throws IOException {
this.results = serializer.deserialize(payload, SecondaryResponse[].class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.smartystreets.api.us_enrichment.result_types.secondary;

import com.fasterxml.jackson.annotation.JsonProperty;

public class Alias {

private String smartyKey;

private String primaryNumber;

private String streetPredirection;

private String streetName;

private String streetSuffix;

private String streetPostdirection;

private String cityName;

private String stateAbbreviation;

private String zipcode;

private String plus4Code;

@JsonProperty("smarty_key")
public String getSmartyKey() {
return smartyKey;
}

@JsonProperty("primary_number")
public String getPrimaryNumber() {
return primaryNumber;
}

@JsonProperty("street_predirection")
public String getStreetPredirection() {
return streetPredirection;
}

@JsonProperty("street_name")
public String getStreetName() {
return streetName;
}

@JsonProperty("street_suffix")
public String getStreetSuffix() {
return streetSuffix;
}

@JsonProperty("street_postdirection")
public String getStreetPostdirection() {
return streetPostdirection;
}

@JsonProperty("city_name")
public String getCityName() {
return cityName;
}

@JsonProperty("state_abbreviation")
public String getStateAbbreviation() {
return stateAbbreviation;
}

@JsonProperty("zipcode")
public String getZipcode() {
return zipcode;
}

@JsonProperty("plus4_code")
public String getPlus4Code() {
return plus4Code;
}

@Override
public String toString() {
return "Alias{" +
"smarty_key='" + getSmartyKey() + '\'' +
", primary_number='" + getPrimaryNumber() + '\'' +
", street_predirection='" + getStreetPredirection() + '\'' +
", street_name='" + getStreetName() + '\'' +
", street_suffix='" + getStreetSuffix() + '\'' +
", street_postdirection='" + getStreetPostdirection() + '\'' +
", city_name='" + getCityName() + '\'' +
", state_abbreviation='" + getStateAbbreviation() + '\'' +
", zipcode='" + getZipcode() + '\'' +
", plus4_code='" + getPlus4Code() + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.smartystreets.api.us_enrichment.result_types.secondary;

import com.fasterxml.jackson.annotation.JsonProperty;

public class RootAddress {

private int secondaryCount;

private String smartyKey;

private String primaryNumber;

private String streetPredirection;

private String streetName;

private String streetSuffix;

private String streetPostdirection;

private String cityName;

private String stateAbbreviation;

private String zipcode;

private String plus4Code;

@JsonProperty("secondary_count")
public int getSecondaryCount() {
return secondaryCount;
}

@JsonProperty("smarty_key")
public String getSmartyKey() {
return smartyKey;
}

@JsonProperty("primary_number")
public String getPrimaryNumber() {
return primaryNumber;
}

@JsonProperty("street_predirection")
public String getStreetPredirection() {
return streetPredirection;
}

@JsonProperty("street_name")
public String getStreetName() {
return streetName;
}

@JsonProperty("street_suffix")
public String getStreetSuffix() {
return streetSuffix;
}

@JsonProperty("street_postdirection")
public String getStreetPostdirection() {
return streetPostdirection;
}

@JsonProperty("city_name")
public String getCityName() {
return cityName;
}

@JsonProperty("state_abbreviation")
public String getStateAbbreviation() {
return stateAbbreviation;
}

@JsonProperty("zipcode")
public String getZipcode() {
return zipcode;
}

@JsonProperty("plus4_code")
public String getPlus4Code() {
return plus4Code;
}

@Override
public String toString() {
return "RootAddress{" +
"secondary_count=" + getSecondaryCount() +
", smarty_key='" + getSmartyKey() + '\'' +
", primary_number='" + getPrimaryNumber() + '\'' +
", street_predirection='" + getStreetPredirection() + '\'' +
", street_name='" + getStreetName() + '\'' +
", street_suffix='" + getStreetSuffix() + '\'' +
", street_postdirection='" + getStreetPostdirection() + '\'' +
", city_name='" + getCityName() + '\'' +
", state_abbreviation='" + getStateAbbreviation() + '\'' +
", zipcode='" + getZipcode() + '\'' +
", plus4_code='" + getPlus4Code() + '\'' +
'}';
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.smartystreets.api.us_enrichment.result_types.secondary;

import com.fasterxml.jackson.annotation.JsonProperty;

public class Secondary {

private String smartyKey;

private String secondaryDesignator;

private String secondaryNumber;

private String plus4Code;

@JsonProperty("smarty_key")
public String getSmartyKey() {
return smartyKey;
}

@JsonProperty("secondary_designator")
public String getSecondaryDesignator() {
return secondaryDesignator;
}

@JsonProperty("secondary_number")
public String getSecondaryNumber() {
return secondaryNumber;
}

@JsonProperty("plus4_code")
public String getPlus4Code() {
return plus4Code;
}

@Override
public String toString() {
return "Secondary{" +
"smarty_key='" + getSmartyKey() + '\'' +
", secondary_designator='" + getSecondaryDesignator() + '\'' +
", secondary_number='" + getSecondaryNumber() + '\'' +
", plus4_code='" + getPlus4Code() + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.smartystreets.api.us_enrichment.result_types.secondary;

import com.fasterxml.jackson.annotation.JsonProperty;

public class SecondaryCountResponse {

private String smartyKey;

private int count;

@JsonProperty("smarty_key")
public String getSmartyKey() {
return smartyKey;
}

@JsonProperty("count")
public int getCount() {
return count;
}

@Override
public String toString() {
return "SecondaryCountResponse{" +
"smartyKey='" + smartyKey + '\'' +
", count=" + count +
'}';
}
}
Loading

0 comments on commit 0854a20

Please sign in to comment.