Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/com/smartystreets/api/ClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ public ClientBuilder withFeatureComponentAnalysis() {
return withCustomCommaSeparatedQuery("features", "component-analysis");
}

/**
* Adds to the request query to use the IANA timezone feature.
* @return Returns <b>this</b> to accommodate method chaining.
*/
public ClientBuilder withFeatureIANATimeZone() {
return withCustomCommaSeparatedQuery("features", "iana-timezone");
}

// Package-private for testing
Map<String, String> getCustomQueries() {
return this.customQueries;
}

public com.smartystreets.api.international_street.Client buildInternationalStreetApiClient() {
this.ensureURLPrefixNotNull(INTERNATIONAL_STREET_API_URL);
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/com/smartystreets/api/us_street/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class Metadata implements Serializable {
private String timeZone;
private double utcOffset;
private boolean obeysDst;
private String ianaTimeZone;
private double ianaUtcOffset;
private boolean ianaDst;
private boolean ewsMatch;

//endregion
Expand Down Expand Up @@ -106,8 +109,6 @@ public String getTimeZone() {
return this.timeZone;
}

// TODO: Coordinate Licensei

@JsonProperty("utc_offset")
public double getUtcOffset() {
return this.utcOffset;
Expand All @@ -118,6 +119,21 @@ public boolean obeysDst() {
return this.obeysDst;
}

@JsonProperty("iana_time_zone")
public String getIanaTimeZone() {
return this.ianaTimeZone;
}

@JsonProperty("iana_utc_offset")
public double getIanaUtcOffset() {
return this.ianaUtcOffset;
}

@JsonProperty("iana_dst")
public boolean isIanaDst() {
return this.ianaDst;
}

@JsonProperty("ews_match")
public boolean isEwsMatch() {
return this.ewsMatch;
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/com/smartystreets/api/ClientBuilderTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.smartystreets.api;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class ClientBuilderTest {

@Test
public void testWithFeatureIANATimeZone() {
ClientBuilder builder = new ClientBuilder("id", "token")
.withFeatureIANATimeZone();

assertEquals("iana-timezone", builder.getCustomQueries().get("features"));
}

@Test
public void testWithFeatureIANATimeZoneAppendsWhenCombinedWithComponentAnalysis() {
ClientBuilder builder = new ClientBuilder("id", "token")
.withFeatureComponentAnalysis()
.withFeatureIANATimeZone();

assertEquals("component-analysis,iana-timezone", builder.getCustomQueries().get("features"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void testFullJSONDeserialization() throws Exception {
+ "\"time_zone\": \"Mountain\",\n"
+ "\"utc_offset\": -7,\n"
+ "\"dst\": true,\n"
+ "\"iana_time_zone\": \"America/Denver\",\n"
+ "\"iana_utc_offset\": -7,\n"
+ "\"iana_dst\": true,\n"
+ "\"ews_match\": true\n"
+ "},\n"
+ "\"analysis\": {\n"
Expand Down Expand Up @@ -168,6 +171,9 @@ public void testFullJSONDeserialization() throws Exception {
assertEquals("Mountain", candidates[0].getMetadata().getTimeZone());
assertEquals(-7, candidates[0].getMetadata().getUtcOffset(), 1);
assertEquals(true, candidates[0].getMetadata().obeysDst());
assertEquals("America/Denver", candidates[0].getMetadata().getIanaTimeZone());
assertEquals(-7, candidates[0].getMetadata().getIanaUtcOffset(), 1);
assertEquals(true, candidates[0].getMetadata().isIanaDst());
assertEquals(true, candidates[0].getMetadata().isEwsMatch());
assertEquals("S", candidates[0].getAnalysis().getDpvMatchCode());
assertEquals("AACCRR", candidates[0].getAnalysis().getDpvFootnotes());
Expand Down