Skip to content

Commit

Permalink
Added country code to ip-api.com.
Browse files Browse the repository at this point in the history
  • Loading branch information
Timthreetwelve committed Nov 28, 2024
1 parent dc8c4bc commit 7e0029f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion GetMyIP/Constants/AppConstString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static class AppConstString
/// <value>
/// The URL including all of the parameters specified in the URL.
/// </value>
public static string IpApiUrl { get; } = "http://ip-api.com/json/?fields=status,message,country,continent,regionName,city,zip,lat,lon,timezone,offset,isp,asname,as,query";
public static string IpApiUrl { get; } = "http://ip-api.com/json/?fields=status,message,country,countryCode,continent,regionName,city,zip,lat,lon,timezone,offset,isp,asname,as,query";

/// <summary>
/// Gets the URL for freeipapi.com
Expand Down
1 change: 1 addition & 0 deletions GetMyIP/Helpers/IpHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ private static void ProcessIPApiCom(string? json, bool quiet)
IPInfo.GeoInfoList.Add(new IPInfo(GetStringResource("External_State"), _infoIpApi.State));
IPInfo.GeoInfoList.Add(new IPInfo(GetStringResource("External_PostalCode"), _infoIpApi.Zip));
IPInfo.GeoInfoList.Add(new IPInfo(GetStringResource("External_Country"), _infoIpApi.Country));
IPInfo.GeoInfoList.Add(new IPInfo(GetStringResource("External_CountryCode"), _infoIpApi.CountryCode));
IPInfo.GeoInfoList.Add(new IPInfo(GetStringResource("External_Continent"), _infoIpApi.Continent));
IPInfo.GeoInfoList.Add(new IPInfo(GetStringResource("External_Longitude"), _infoIpApi.Lon.ToString(CultureInfo.InvariantCulture)));
IPInfo.GeoInfoList.Add(new IPInfo(GetStringResource("External_Latitude"), _infoIpApi.Lat.ToString(CultureInfo.InvariantCulture)));
Expand Down
5 changes: 5 additions & 0 deletions GetMyIP/Models/IpApiCom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public class IpApiCom
/// </summary>
public string Country { get; init; } = string.Empty;

/// <summary>
/// Country: Country code
/// </summary>
public string CountryCode { get; init; } = string.Empty;

/// <summary>
/// RegionName: Region/State
/// </summary>
Expand Down

0 comments on commit 7e0029f

Please sign in to comment.