From 7e0029fb38e2cc439e9633091e1622763468e579 Mon Sep 17 00:00:00 2001 From: Tim Kennedy Date: Wed, 27 Nov 2024 20:16:23 -0600 Subject: [PATCH] Added country code to ip-api.com. --- GetMyIP/Constants/AppConstString.cs | 2 +- GetMyIP/Helpers/IpHelpers.cs | 1 + GetMyIP/Models/IpApiCom.cs | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/GetMyIP/Constants/AppConstString.cs b/GetMyIP/Constants/AppConstString.cs index 5f368d3..1b57038 100644 --- a/GetMyIP/Constants/AppConstString.cs +++ b/GetMyIP/Constants/AppConstString.cs @@ -32,7 +32,7 @@ public static class AppConstString /// /// The URL including all of the parameters specified in the URL. /// - 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"; /// /// Gets the URL for freeipapi.com diff --git a/GetMyIP/Helpers/IpHelpers.cs b/GetMyIP/Helpers/IpHelpers.cs index 26ad997..82b2cdd 100644 --- a/GetMyIP/Helpers/IpHelpers.cs +++ b/GetMyIP/Helpers/IpHelpers.cs @@ -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))); diff --git a/GetMyIP/Models/IpApiCom.cs b/GetMyIP/Models/IpApiCom.cs index e8ab8d0..ee6c0d7 100644 --- a/GetMyIP/Models/IpApiCom.cs +++ b/GetMyIP/Models/IpApiCom.cs @@ -22,6 +22,11 @@ public class IpApiCom /// public string Country { get; init; } = string.Empty; + /// + /// Country: Country code + /// + public string CountryCode { get; init; } = string.Empty; + /// /// RegionName: Region/State ///