diff --git a/us-street-api/lookup.go b/us-street-api/lookup.go index 428c8a4..f171724 100644 --- a/us-street-api/lookup.go +++ b/us-street-api/lookup.go @@ -21,6 +21,7 @@ type Lookup struct { MaxCandidates int `json:"candidates,omitempty"` // Default value: 1 MatchStrategy MatchStrategy `json:"match,omitempty"` OutputFormat OutputFormat `json:"format,omitempty"` + CountySource CountySource `json:"county_source,omitempty"` Results []*Candidate `json:"results,omitempty"` } @@ -47,6 +48,9 @@ func (l *Lookup) encodeQueryString(query url.Values) { if l.OutputFormat != FormatDefault { encode(query, string(l.OutputFormat), "format") } + if l.CountySource != PostalCounty { + encode(query, string(l.CountySource), "county_source") + } } func encode(query url.Values, source string, target string) { if source != "" { @@ -70,3 +74,10 @@ const ( FormatDefault = OutputFormat("default") FormatProjectUSA = OutputFormat("project-usa") ) + +type CountySource string + +const ( + PostalCounty = CountySource("postal") + GeographicCounty = CountySource("geographic") +) diff --git a/us-street-api/lookup_test.go b/us-street-api/lookup_test.go index b52efe6..7efdf1b 100644 --- a/us-street-api/lookup_test.go +++ b/us-street-api/lookup_test.go @@ -79,3 +79,11 @@ func (this *LookupFixture) TestQueryStringEncoding_OutputFormatSerialized() { "format": {"project-usa"}, }) } + +func (this *LookupFixture) TestQueryStringEncoding_CountySourceSerialized() { + this.So(this.encode(&Lookup{ + CountySource: GeographicCounty, + }), should.Resemble, url.Values{ + "county_source": {"geographic"}, + }) +}