Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
nil
return in the followingGeocoder::Result::Mapbox
methods:city
,state
,state_code
,postal_code
,country
,country_code
, andneighborhood
.Explanation
Given the following example of a "region" type response, the
Geocoder::Result::Mapbox
class will not return a value for thestate
orstate_code
methods despite the necessary data existing in the payload:The incumbent logic assumes that there is an array item in
context
that will have anid
containing the "region" string. Since there isn't one,nil
is returned from thestate
andstate_code
methods. However, theid
in the top-level of the object does contain the "region" string because it is a region type response. This means that the top-leveltext
property is the value that should be returned in thestate
method, and the top-levelproperties.short_code
should be returned asstate_code
.This same pattern holds true for the other types of responses. The base payload "type" (id) determines whether or not values for certain methods should be pulled from a
context
list item or from the basetext
/properties
.