Skip to content

Commit a3407f5

Browse files
Move addressSearch to where it belongs
1 parent 260da45 commit a3407f5

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

us-enrichment-api/client.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,29 @@ func buildRequest(lookup enrichmentLookup) *http.Request {
109109
func buildLookupURL(lookup enrichmentLookup) string {
110110
var newLookupURL string
111111
if len(lookup.getDataSubset()) == 0 {
112-
newLookupURL = strings.Replace(lookupURLWithoutSubSet, lookupURLSmartyKey, lookup.getSmartyKey(), 1)
112+
newLookupURL = strings.Replace(lookupURLWithoutSubSet, lookupURLSmartyKey, getLookupURLSmartyKeyReplacement(lookup), 1)
113113
} else {
114-
newLookupURL = strings.Replace(lookupURLWithSubSet, lookupURLSmartyKey, lookup.getSmartyKey(), 1)
114+
newLookupURL = strings.Replace(lookupURLWithSubSet, lookupURLSmartyKey, getLookupURLSmartyKeyReplacement(lookup), 1)
115115
}
116116

117117
newLookupURL = strings.Replace(newLookupURL, lookupURLDataSet, lookup.getDataSet(), 1)
118118
return strings.TrimSuffix(strings.Replace(newLookupURL, lookupURLDataSubSet, lookup.getDataSubset(), 1), "/")
119119
}
120120

121+
func getLookupURLSmartyKeyReplacement(lookup enrichmentLookup) string {
122+
if len(lookup.getSmartyKey()) > 0 {
123+
return lookup.getSmartyKey()
124+
} else {
125+
return addressSearch
126+
}
127+
}
128+
121129
const (
122130
lookupURLSmartyKey = ":smartykey"
123131
lookupURLDataSet = ":dataset"
124132
lookupURLDataSubSet = ":datasubset"
125133
lookupURLWithSubSet = "/lookup/" + lookupURLSmartyKey + "/" + lookupURLDataSet + "/" + lookupURLDataSubSet // Remaining parts will be completed later by the sdk.BaseURLClient.
126134
lookupURLWithoutSubSet = "/lookup/" + lookupURLSmartyKey + "/" + lookupURLDataSet // Remaining parts will be completed later by the sdk.BaseURLClient.
127135
lookupETagHeader = "Etag"
136+
addressSearch = "search"
128137
)

us-enrichment-api/lookup.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ type universalLookup struct {
3737
}
3838

3939
func (g *universalLookup) getSmartyKey() string {
40-
if len(g.Lookup.SmartyKey) == 0 {
41-
return addressSearch
42-
}
4340
return g.Lookup.SmartyKey
4441
}
4542
func (g *universalLookup) getDataSet() string { return g.DataSet }
@@ -87,9 +84,6 @@ type financialLookup struct {
8784
}
8885

8986
func (f *financialLookup) getSmartyKey() string {
90-
if len(f.Lookup.SmartyKey) == 0 {
91-
return addressSearch
92-
}
9387
return f.Lookup.SmartyKey
9488
}
9589

@@ -143,9 +137,6 @@ type principalLookup struct {
143137
}
144138

145139
func (p *principalLookup) getSmartyKey() string {
146-
if len(p.Lookup.SmartyKey) == 0 {
147-
return addressSearch
148-
}
149140
return p.Lookup.SmartyKey
150141
}
151142

@@ -213,9 +204,6 @@ func (g *geoReferenceLookup) populate(query url.Values) {
213204
}
214205

215206
func (g *geoReferenceLookup) getSmartyKey() string {
216-
if len(g.Lookup.SmartyKey) == 0 {
217-
return addressSearch
218-
}
219207
return g.Lookup.SmartyKey
220208
}
221209

@@ -255,9 +243,6 @@ type secondaryLookup struct {
255243
}
256244

257245
func (s *secondaryLookup) getSmartyKey() string {
258-
if len(s.Lookup.SmartyKey) == 0 {
259-
return addressSearch
260-
}
261246
return s.SmartyKey
262247
}
263248

@@ -311,9 +296,6 @@ type secondaryCountLookup struct {
311296
}
312297

313298
func (s *secondaryCountLookup) getSmartyKey() string {
314-
if len(s.Lookup.SmartyKey) == 0 {
315-
return addressSearch
316-
}
317299
return s.SmartyKey
318300
}
319301

@@ -367,7 +349,6 @@ const (
367349
secondaryData = "secondary"
368350
secondaryDataCount = "count"
369351
emptyDataSubset = ""
370-
addressSearch = "search"
371352
)
372353

373354
func (l Lookup) populateInclude(query url.Values) {

0 commit comments

Comments
 (0)