Skip to content

Commit

Permalink
Fixning the Quality Gate errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Clifftech123 committed May 31, 2024
1 parent 1f311ee commit 1d0d1ef
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 56 deletions.
7 changes: 4 additions & 3 deletions sample/CountryData.Sample.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CountryData.Standard;

using CountryData.Standard;

/// <summary>
/// Main program class for demonstrating the use of the CountryData library.
Expand All @@ -13,7 +14,7 @@ class Program
/// <summary>
/// Entry point of the program.
/// </summary>
static void Main()
public static void Main()
{
GetCountries();
GetCountryByCode("US");
Expand Down Expand Up @@ -111,7 +112,7 @@ static void GetCountryByPhoneCode(string phoneCode)
Console.WriteLine($"Countries for phone code {phoneCode}:");
foreach (var country in countries)
{
Console.WriteLine(country.CountryName);
Console.WriteLine(country.CountryName);
}
}

Expand Down
30 changes: 19 additions & 11 deletions sample/CountryData.Sample.Web.API/Controllers/CountryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public CountryController(CountryHelper helper)
/// </summary>
/// <returns>A list of all countries. If no countries are found, a NotFound result is returned.</returns>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<Country>), 200)]
[ProducesResponseType(404)]
public IActionResult GetCountries()
{
var countries = _helper.GetCountries();
Expand All @@ -41,6 +43,8 @@ public IActionResult GetCountries()
/// <param name="countryCode">The ISO country code.</param>
/// <returns>The data for the specified country. If no data is found, a NotFound result is returned.</returns>
[HttpGet("country")]
[ProducesResponseType(typeof(Country), 200)]
[ProducesResponseType(404)]
public IActionResult GetCountryByCode([FromQuery] string countryCode)
{
var country = _helper.GetCountryByCode(countryCode);
Expand All @@ -52,8 +56,6 @@ public IActionResult GetCountryByCode([FromQuery] string countryCode)
}




/// <summary>
/// Returns comprehensive data for all countries.
/// </summary>
Expand All @@ -62,6 +64,8 @@ public IActionResult GetCountryByCode([FromQuery] string countryCode)
/// If no data is found, a NotFound result is

[HttpGet("countries")]
[ProducesResponseType(typeof(IEnumerable<Country>), 200)]
[ProducesResponseType(404)]
public IActionResult GetCountryData()
{
var country = _helper.GetCountryData();
Expand All @@ -70,16 +74,18 @@ public IActionResult GetCountryData()
return NotFound();
}
return Ok(country);

}



/// <summary>
/// Retrieves the regions for a given country code.
/// </summary>
/// <param name="countryCode">The ISO country code.</param>
/// <returns>A list of regions for the specified country. If no regions are found, a NotFound result is returned.</returns>
[HttpGet("regions")]
[ProducesResponseType(typeof(IEnumerable<Regions>), 200)]
[ProducesResponseType(404)]
public IActionResult GetRegionsByCountryCode([FromQuery] string countryCode)
{
var regions = _helper.GetRegionByCountryCode(countryCode);
Expand All @@ -91,21 +97,21 @@ public IActionResult GetRegionsByCountryCode([FromQuery] string countryCode)
}



/// <summary>
/// Retrieves the emoji flag for a given country short code.
/// </summary>
/// <param name="shortCode">The short code of the country.</param>
/// <returns>The emoji flag for the specified country. If no flag is found, a NotFound result is returned.</returns>
[HttpGet("flag")]
public IActionResult GetCountryFlag([FromQuery] string shortCode)
[ProducesResponseType(typeof(string), 200)]
[ProducesResponseType(404)]
public IActionResult GetCountryFlag([FromQuery] string countryCode)
{
var flag = _helper.GetCountryEmojiFlag(shortCode);
var flag = _helper.GetCountryEmojiFlag(countryCode);
if (flag == null)
{
return NotFound();
}

return Ok(flag);
}

Expand All @@ -116,14 +122,15 @@ public IActionResult GetCountryFlag([FromQuery] string shortCode)
/// <param name="shortCode">The short code of the country.</param>
/// <returns>The phone code for the specified country. If no phone code is found, a NotFound result is returned.</returns>
[HttpGet("phoneCodeByShortCode")]
public IActionResult GetPhoneCodeByCountryShortCode([FromQuery] string shortCode)
[ProducesResponseType(typeof(string), 200)]
[ProducesResponseType(404)]
public IActionResult GetPhoneCodeByCountryShortCode([FromQuery] string countryCode)
{
var phoneCode = _helper.GetPhoneCodeByCountryShortCode(shortCode);
var phoneCode = _helper.GetPhoneCodeByCountryShortCode(countryCode);
if (phoneCode == null)
{
return NotFound();
}

return Ok(phoneCode);
}

Expand All @@ -133,14 +140,15 @@ public IActionResult GetPhoneCodeByCountryShortCode([FromQuery] string shortCode
/// <param name="phoneCode">The phone code of the country.</param>
/// <returns>The data for the specified country. If no data is found, a NotFound result is returned.</returns>
[HttpGet("countryByPhoneCode")]
[ProducesResponseType(typeof(Country), 200)]
[ProducesResponseType(404)]
public IActionResult GetCountryByPhoneCode([FromQuery] string phoneCode)
{
var countryDataByPhoneCode = _helper.GetCountriesByPhoneCode(phoneCode);
if (countryDataByPhoneCode == null)
{
return NotFound();
}

return Ok(countryDataByPhoneCode);
}

Expand Down
41 changes: 0 additions & 41 deletions sample/CountryData.Sample.Web.API/CountryData.Sample.Web.API.http
Original file line number Diff line number Diff line change
@@ -1,41 +0,0 @@
@CountryInforAPI_HostAddress = http://localhost:5016

# Retrieves the default country information
GET {{CountryInforAPI_HostAddress}}/Country
Accept: application/json

###

# Retrieves a list of all countries
GET {{CountryInforAPI_HostAddress}}/Country/countries
Accept: application/json

###

# Retrieves the regions for the country with the code 'US'
GET {{CountryInforAPI_HostAddress}}/Country/US/regions
Accept: application/json

###

# Retrieves the country information for the country with the code 'GH'
GET {{CountryInforAPI_HostAddress}}/Country/GH/countries
Accept: application/json

###

# Retrieves the emoji flag for the country with the code 'US'
GET {{CountryInforAPI_HostAddress}}/Country/US/flag
Accept: application/json

###
# Retrieves the phone code for the country with the code 'US'
GET {{CountryInforAPI_HostAddress}}/Country/GH/phoneCode
Accept: application/json

###
# Retrieves the country information for the country with the phone code '1'
GET {{CountryInforAPI_HostAddress}}/Country/phoneCode/+233
Accept: application/json

###
3 changes: 2 additions & 1 deletion src/CountryData.Standard/CountryData.Standard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<Version>1.4.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<ReleaseNotes>Added new functionality to get country phone codes</ReleaseNotes>
</PropertyGroup>

Expand All @@ -25,6 +24,8 @@
</EmbeddedResource>
</ItemGroup>



<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
Expand Down

0 comments on commit 1d0d1ef

Please sign in to comment.