Skip to content

Commit 3a65201

Browse files
committed
Refactor: Update documentation and samples, enrich README with method explanations, and rename GetCountryEmojiFlag to GetCountryFlag for clarity.
1 parent 23b7fa6 commit 3a65201

6 files changed

Lines changed: 27 additions & 9 deletions

File tree

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ For more detailed instructions and comprehensive information about the library,
8181
.ToList();
8282
```
8383

84-
84+
### Get Country Data by Country Code
8585
This example demonstrates how to retrieve a country with a specific phone code using the `GetCountryByPhoneCode` method. In this case, we're fetching the country with the phone code "+233".
8686

8787
```csharp
@@ -90,6 +90,24 @@ Console.WriteLine(CountryName);
9090
```
9191

9292

93+
94+
95+
### Methods and Descriptions
96+
97+
The CountryData.Standard library provides a set of methods that allow you to retrieve country data, flags, regions, and phone codes. The following table lists the available methods and their descriptions.
98+
99+
| Method | Description |
100+
|--------|-------------|
101+
| [`GetCountryData()`](./docs/README.md) | Returns all country data including region, short code, and country name. |
102+
| [`GetCountryByCode(string shortCode)`](./docs/README.md) | Returns a single country's data by its short code. |
103+
| [`GetCountryFlag(string shortCode)`](./docs/README.md) | Gets the flag of the country, represented as an emoji, by the country's short code. |
104+
| [`GetRegionByCountryCode(string ShortCode)`](./docs/README.md) | Selects and returns a list of regions for a particular country identified by its short code. |
105+
| [`GetCountries()`](./docs/README.md) | Gets the list of all country names. |
106+
| [`GetPhoneCodeByCountryShortCode(string shortCode)`](./docs/README.md) | Returns a single country's phone code by its short code. |
107+
| [`GetCountryByPhoneCode(string phoneCode)`](./docs/README.md) | Returns country data for the country associated with the specified phone code. |
108+
109+
110+
93111
### ISO-3166-1 country codes
94112

95113
For a list of supported ISO-3166-1 country codes, PhoneCode, Flags, ISO and , Unicode please refer to the [Country Details](./CountryData/CountryDetails.md) file.

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ This method is particularly useful for applications that need to display or anal
116116

117117

118118

119-
### GetCountryEmojiFlag(string shortCode)
119+
### GetCountryFlag (string shortCode)
120120

121-
The `GetCountryEmojiFlag()` method is designed to fetch the flag of a specific country using its ISO 3166-1 alpha-2 code. This method provides a simple and effective way to visually represent countries in your application.
121+
The `GetCountryFlag ()` method is designed to fetch the flag of a specific country using its ISO 3166-1 alpha-2 code. This method provides a simple and effective way to visually represent countries in your application.
122122

123123
Here's the method signature in C#:
124124

125125
```csharp
126-
string GetCountryEmojiFlag(string shortCode);
126+
string GetCountryFlag (string shortCode);
127127
```
128128

129129
This method returns the em flag of the country corresponding to the provided ISO code. It's particularly useful when you need to display a country's flag in a user interface or in text-based communication.

sample/CountryData.Sample.Console/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void GetRegionsByCountryCode(string countryCode)
8383
/// <param name="shortCode">The country short code.</param>
8484
static void GetCountryFlag(string shortCode)
8585
{
86-
var flag = _helper.GetCountryEmojiFlag(shortCode);
86+
var flag = _helper.GetCountryFlag(shortCode);
8787
Console.WriteLine($"Flag for {shortCode}:");
8888
Console.WriteLine(flag);
8989
}

sample/CountryData.Sample.Web.API/Controllers/CountryController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public IActionResult GetRegionsByCountryCode([FromQuery] string countryCode)
107107
[ProducesResponseType(404)]
108108
public IActionResult GetCountryFlag([FromQuery] string countryCode)
109109
{
110-
var flag = _helper.GetCountryEmojiFlag(countryCode);
110+
var flag = _helper.GetCountryFlag(countryCode);
111111
if (flag == null)
112112
{
113113
return NotFound();

src/CountryData.Standard/CountryHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public CountryHelper()
1717
_Countries = JsonConvert.DeserializeObject<List<Country>>(json);
1818
foreach (var country in _Countries)
1919
{
20-
country.CountryFlag = GetCountryEmojiFlag(country.CountryShortCode);
20+
country.CountryFlag = GetCountryFlag(country.CountryShortCode);
2121
}
2222
}
2323

@@ -67,7 +67,7 @@ public Country GetCountryByCode(string shortCode)
6767
/// </summary>
6868
/// <param name="country"></param>
6969
/// <returns></returns>
70-
public string GetCountryEmojiFlag(string shortCode)
70+
public string GetCountryFlag (string shortCode)
7171
{
7272
return string.Concat(shortCode.ToUpper().Select(x => char.ConvertFromUtf32(x + 0x1F1A5)));
7373
}

test/CountryData.UnitTests/CountryHelperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void GetCountryByCode_WithCorrectCode_ShouldReturnCountry(string shortCod
5555
public void GetCountryFlagByCode_WithCorrectCode_ShouldReturnEmojiFlag(string shortCode)
5656
{
5757
//Act
58-
var countryFlag = _countryHelper.GetCountryEmojiFlag(shortCode);
58+
var countryFlag = _countryHelper.GetCountryFlag(shortCode);
5959

6060
//Assert
6161
countryFlag.Should().NotBeNull();

0 commit comments

Comments
 (0)