use of com.smartystreets.api.us_street.Lookup in project API by ca-cwds.
the class SmartyStreet method getSmartyStreetsCandidates.
/**
* @param street incoming street address
* @param city incoming city name
* @param state incoming state
* @param zipCode incoming zip code
* @return returns a address back
*/
public List<Candidate> getSmartyStreetsCandidates(String street, String city, String state, Integer zipCode) {
Client client = new ClientBuilder(smartyStreetsDao.getClientId(), smartyStreetsDao.getToken()).build();
Lookup lookup = createSmartyStreetsLookup(street, city, state, zipCode);
try {
client.send(lookup);
} catch (SmartyException e) {
LOGGER.error("SmartyStreet error, Unable to validate the address", e);
throw new ApiException("ERROR calling SmartyStreet - ", e);
} catch (IOException e) {
LOGGER.error("SmartyStreet IO error, Unable to validate the address", e);
throw new ApiException("ERROR calling SmartyStreet - ", e);
}
return lookup.getResult();
}
use of com.smartystreets.api.us_street.Lookup in project API by ca-cwds.
the class SmartyStreet method createSmartyStreetsLookup.
/**
* @param street incoming street address
* @param city incoming city name
* @param state incoming state
* @param zipCode incoming zip code
* @return returns lookup
*/
public Lookup createSmartyStreetsLookup(String street, String city, String state, Integer zipCode) {
Lookup lookup = new Lookup();
lookup.setStreet(street);
lookup.setCity(city);
lookup.setState(state);
if (zipCode > 0) {
lookup.setZipCode(Integer.toString(zipCode));
} else {
lookup.setZipCode("");
}
lookup.setMaxCandidates(smartyStreetsDao.getMaxCandidates());
return lookup;
}
Aggregations