Search in sources :

Example 1 with Client

use of com.smartystreets.api.us_street.Client 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();
}
Also used : SmartyException(com.smartystreets.api.exceptions.SmartyException) Lookup(com.smartystreets.api.us_street.Lookup) IOException(java.io.IOException) Client(com.smartystreets.api.us_street.Client) ClientBuilder(com.smartystreets.api.us_street.ClientBuilder) ApiException(gov.ca.cwds.rest.api.ApiException)

Aggregations

SmartyException (com.smartystreets.api.exceptions.SmartyException)1 Client (com.smartystreets.api.us_street.Client)1 ClientBuilder (com.smartystreets.api.us_street.ClientBuilder)1 Lookup (com.smartystreets.api.us_street.Lookup)1 ApiException (gov.ca.cwds.rest.api.ApiException)1 IOException (java.io.IOException)1