Skip to content

Commit

Permalink
fix: fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
egbakou authored Feb 9, 2022
1 parent b63b90b commit 942acff
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/RESTCountries.NET/Services/RESTCountriesAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace RESTCountries.Services
/// Defines a <see cref="RESTCountriesAPI" />.
///<para>Get information about countries via a RESTful API.</para>
/// </summary>
public class RESTCountriesAPI
public static class RESTCountriesAPI
{
/// <summary>
/// Defines a RestClient static object.
Expand Down Expand Up @@ -212,17 +212,8 @@ public static async Task<List<Country>> GetCountriesByCallingCodeAsync(string ca
/// <returns>Countries which is in the continent.</returns>
public static async Task<List<Country>> GetCountriesByContinentAsync(string continent)
{
var request = new RestRequest(
$"{RESTCOUNTRIES_BASE_URI}{COUNTRY_BY_CONTINENT}{continent}",
Method.GET,
DataFormat.Json);
IRestResponse response = await client.ExecuteGetAsync(request);
if (response.IsSuccessful && response.StatusCode.HasFlag(HttpStatusCode.OK))
{
JArray jsonArray = JArray.Parse(response.Content);
return jsonArray.ToObject<List<Country>>();
}
throw new CountryNotFoundException("continent", continent);
var allCountries = await GetAllCountriesAsync();
return allCountries.Where(c => string.Equals(c.Region, continent, StringComparison.OrdinalIgnoreCase)).ToList();
}

/// <summary>
Expand Down

0 comments on commit 942acff

Please sign in to comment.