Skip to content

Commit fe5f3e2

Browse files
committed
Support Component Analysis
1 parent e424a6e commit fe5f3e2

File tree

2 files changed

+129
-13
lines changed

2 files changed

+129
-13
lines changed

us-street-api/candidate.go

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,40 @@ type (
7070
// Analysis contains all output fields defined here:
7171
// https://smartystreets.com/docs/us-street-api#analysis
7272
Analysis struct {
73-
DPVMatchCode string `json:"dpv_match_code,omitempty"`
74-
DPVFootnotes string `json:"dpv_footnotes,omitempty"`
75-
DPVCMRACode string `json:"dpv_cmra,omitempty"`
76-
DPVVacantCode string `json:"dpv_vacant,omitempty"`
77-
DPVNoStat string `json:"dpv_no_stat,omitempty"`
78-
Active string `json:"active,omitempty"`
79-
Footnotes string `json:"footnotes,omitempty"` // https://smartystreets.com/docs/us-street-api#footnotes
80-
LACSLinkCode string `json:"lacslink_code,omitempty"`
81-
LACSLinkIndicator string `json:"lacslink_indicator,omitempty"`
82-
SuiteLinkMatch bool `json:"suitelink_match,omitempty"`
83-
EWSMatch bool `json:"ews_match,omitempty"` // deprecated
84-
EnhancedMatch string `json:"enhanced_match,omitempty"` //v2 integration
73+
DPVMatchCode string `json:"dpv_match_code,omitempty"`
74+
DPVFootnotes string `json:"dpv_footnotes,omitempty"`
75+
DPVCMRACode string `json:"dpv_cmra,omitempty"`
76+
DPVVacantCode string `json:"dpv_vacant,omitempty"`
77+
DPVNoStat string `json:"dpv_no_stat,omitempty"`
78+
Active string `json:"active,omitempty"`
79+
Footnotes string `json:"footnotes,omitempty"` // https://smartystreets.com/docs/us-street-api#footnotes
80+
LACSLinkCode string `json:"lacslink_code,omitempty"`
81+
LACSLinkIndicator string `json:"lacslink_indicator,omitempty"`
82+
SuiteLinkMatch bool `json:"suitelink_match,omitempty"`
83+
EWSMatch bool `json:"ews_match,omitempty"` // deprecated
84+
EnhancedMatch string `json:"enhanced_match,omitempty"` //v2 integration
85+
Components ComponentAnalysis `json:"components,omitempty"`
86+
}
87+
88+
ComponentAnalysis struct {
89+
PrimaryNumber MatchInfo `json:"primary_number,omitempty"`
90+
StreetPredirection MatchInfo `json:"street_predirection,omitempty"`
91+
StreetName MatchInfo `json:"street_name,omitempty"`
92+
StreetPostdirection MatchInfo `json:"street_postdirection,omitempty"`
93+
StreetSuffix MatchInfo `json:"street_suffix,omitempty"`
94+
SecondaryNumber MatchInfo `json:"secondary_number,omitempty"`
95+
SecondaryDesignator MatchInfo `json:"secondary_designator,omitempty"`
96+
ExtraSecondaryNumber MatchInfo `json:"extra_secondary_number,omitempty"`
97+
ExtraSecondaryDesignator MatchInfo `json:"extra_secondary_designator,omitempty"`
98+
CityName MatchInfo `json:"city_name,omitempty"`
99+
StateAbbreviation MatchInfo `json:"state_abbreviation,omitempty"`
100+
ZIPCode MatchInfo `json:"zipcode,omitempty"`
101+
Plus4Code MatchInfo `json:"plus4_code,omitempty"`
102+
Urbanization MatchInfo `json:"urbanization,omitempty"`
103+
}
104+
105+
MatchInfo struct {
106+
Status string `json:"status,omitempty"`
107+
Change []string `json:"change,omitempty"`
85108
}
86109
)

us-street-api/client_test.go

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,42 @@ func (f *ClientFixture) TestFullJSONResponseDeserialization() {
198198
"lacslink_code": "lacslink_code",
199199
"lacslink_indicator": "lacslink_indicator",
200200
"suitelink_match": true,
201-
"enhanced_match": "enhanced_match"
201+
"enhanced_match": "enhanced_match",
202+
"components": {
203+
"primary_number": {
204+
"status": "confirmed"
205+
},
206+
"street_predirection": {
207+
"status": "confirmed",
208+
"change": ["added"]
209+
},
210+
"street_name": {
211+
"status": "confirmed"
212+
},
213+
"street_suffix": {
214+
"status": "confirmed",
215+
"change": ["added"]
216+
},
217+
"secondary_number": {
218+
"status": "unconfirmed"
219+
},
220+
"secondary_designator": {
221+
"status": "unconfirmed"
222+
},
223+
"city_name": {
224+
"status": "confirmed"
225+
},
226+
"state_abbreviation": {
227+
"status": "confirmed"
228+
},
229+
"zipcode": {
230+
"status": "confirmed"
231+
},
232+
"plus4_code": {
233+
"status": "confirmed",
234+
"change": ["corrected"]
235+
}
236+
}
202237
}
203238
}
204239
]`
@@ -271,6 +306,64 @@ func (f *ClientFixture) TestFullJSONResponseDeserialization() {
271306
SuiteLinkMatch: true,
272307
EWSMatch: false,
273308
EnhancedMatch: "enhanced_match",
309+
Components: ComponentAnalysis{
310+
PrimaryNumber: MatchInfo{
311+
Status: "confirmed",
312+
Change: nil,
313+
},
314+
StreetPredirection: MatchInfo{
315+
Status: "confirmed",
316+
Change: []string{"added"},
317+
},
318+
StreetName: MatchInfo{
319+
Status: "confirmed",
320+
Change: nil,
321+
},
322+
StreetPostdirection: MatchInfo{
323+
Status: "",
324+
Change: nil,
325+
},
326+
StreetSuffix: MatchInfo{
327+
Status: "confirmed",
328+
Change: []string{"added"},
329+
},
330+
SecondaryNumber: MatchInfo{
331+
Status: "unconfirmed",
332+
Change: nil,
333+
},
334+
SecondaryDesignator: MatchInfo{
335+
Status: "unconfirmed",
336+
Change: nil,
337+
},
338+
ExtraSecondaryNumber: MatchInfo{
339+
Status: "",
340+
Change: nil,
341+
},
342+
ExtraSecondaryDesignator: MatchInfo{
343+
Status: "",
344+
Change: nil,
345+
},
346+
CityName: MatchInfo{
347+
Status: "confirmed",
348+
Change: nil,
349+
},
350+
StateAbbreviation: MatchInfo{
351+
Status: "confirmed",
352+
Change: nil,
353+
},
354+
ZIPCode: MatchInfo{
355+
Status: "confirmed",
356+
Change: nil,
357+
},
358+
Plus4Code: MatchInfo{
359+
Status: "confirmed",
360+
Change: []string{"corrected"},
361+
},
362+
Urbanization: MatchInfo{
363+
Status: "",
364+
Change: nil,
365+
},
366+
},
274367
},
275368
},
276369
})

0 commit comments

Comments
 (0)