Skip to content

Commit

Permalink
fix(arcgis): updating the parameter names for deserialization of coun…
Browse files Browse the repository at this point in the history
…try information
  • Loading branch information
JustinCanton committed Oct 16, 2024
1 parent b0e40cf commit 50e20e7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/Geo.ArcGIS/Models/Responses/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public class Address
[JsonPropertyName("PostalExt")]
public string PostalCodeExtension { get; set; }

/// <summary>
/// Gets or sets the country of the address.
/// </summary>
[JsonPropertyName("CntryName")]
public string Country { get; set; }

/// <summary>
/// Gets or sets the country code of the address.
/// </summary>
Expand Down
11 changes: 10 additions & 1 deletion src/Geo.ArcGIS/Models/Responses/LocationAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ public class LocationAttribute : Attribute
[JsonPropertyName("CountryCode")]
public string CountryCode { get; set; }

/// <summary>
/// Sets the country code by an alternate name.
/// </summary>
[JsonPropertyName("Country")]
public string AlternateCountryCode
{
set { CountryCode = value; }
}

/// <summary>
/// Gets or sets the location name.
/// </summary>
Expand Down Expand Up @@ -304,7 +313,7 @@ public class LocationAttribute : Attribute
/// <summary>
/// Gets or sets the country of a location.
/// </summary>
[JsonPropertyName("Country")]
[JsonPropertyName("CntryName")]
public string Country { get; set; }

/// <summary>
Expand Down
10 changes: 8 additions & 2 deletions test/Geo.ArcGIS.Tests/Services/ArcGISGeocodingShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public ArcGISGeocodingShould()
"{ \"address\":{ \"Match_addr\":\"Cali's California Style Burritos\", \"LongLabel\":\"Cali's California Style Burritos, 3046 Dolphin Dr, Elizabethtown, KY, 42701, USA\"," +
"\"ShortLabel\":\"Cali's California Style Burritos\", \"Addr_type\":\"POI\", \"Type\":\"Mexican Food\", \"PlaceName\":\"Cali's California Style Burritos\"," +
"\"AddNum\":\"3046\", \"Address\":\"3046 Dolphin Dr\", \"Block\":\"\", \"Sector\":\"\", \"Neighborhood\":\"\", \"District\":\"\", \"City\":\"Elizabethtown\", \"MetroArea\":\"\"," +
"\"Subregion\":\"Hardin County\", \"Region\":\"Kentucky\", \"Territory\":\"\", \"Postal\":\"42701\", \"PostalExt\":\"\", \"CountryCode\":\"USA\" }," +
"\"Subregion\":\"Hardin County\", \"Region\":\"Kentucky\", \"Territory\":\"\", \"Postal\":\"42701\", \"PostalExt\":\"\", \"CountryCode\":\"USA\", \"CntryName\":\"United States of America\" }," +
"\"location\":{ \"x\":-85.837039999999945,\"y\":37.710620000000063,\"spatialReference\":{ \"wkid\":4326,\"latestWkid\":4326} }}"),
});

Expand Down Expand Up @@ -112,7 +112,8 @@ public ArcGISGeocodingShould()
{
StatusCode = HttpStatusCode.OK,
Content = new StringContent("{\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326},\"candidates\":[{\"address\":\"123 East\",\"location\":{\"x\":-85.837039999999945,\"y\":37.710620000000063}," +
"\"score\":100,\"attributes\":{\"Match_addr\":\"123 East\",\"Addr_type\":\"POI\"},\"extent\":{\"xmin\":-85.84203999999994,\"ymin\":37.70562000000006,\"xmax\":-85.832039999999949,\"ymax\":37.715620000000065}}]}"),
"\"score\":100,\"attributes\":{\"LongLabel\": \"123 Main Street, Walton, Street, Somerset, England, BA16 9QL, GBR\",\"ShortLabel\": \"123 Main Street\",\"Addr_type\": \"StreetAddress\"," +
"\"CntryName\":\"United States of America\", \"Country\":\"USA\"},\"extent\":{\"xmin\":-85.84203999999994,\"ymin\":37.70562000000006,\"xmax\":-85.832039999999949,\"ymax\":37.715620000000065}}]}"),
});

mockHandler
Expand Down Expand Up @@ -580,6 +581,8 @@ public async Task ReverseGeocodingAsyncSuccessfully()
var response = await sut.ReverseGeocodingAsync(parameters);
response.Address.MatchAddress.Should().Be("Cali's California Style Burritos");
response.Location.Longitude.Should().Be(-85.837039999999945);
response.Address.Country.Should().Be("United States of America");
response.Address.CountryCode.Should().Be("USA");
}

/// <summary>
Expand Down Expand Up @@ -636,6 +639,9 @@ public async Task AddressCandidateAsyncSuccessfully()
var response = await sut.AddressCandidateAsync(parameters);
response.Candidates.Count.Should().Be(1);
response.SpatialReference.WellKnownID.Should().Be(4326);
response.Candidates[0].Attributes.Should().NotBeNull();
(response.Candidates[0].Attributes as LocationAttribute).Country.Should().Be("United States of America");
(response.Candidates[0].Attributes as LocationAttribute).CountryCode.Should().Be("USA");
}

/// <summary>
Expand Down

0 comments on commit 50e20e7

Please sign in to comment.