I have interface with this code
interface IHttpRequest
{
Task<string> GetCountries();
}
That I inherit in class like this
public class GettingCountries: IHttpRequest
{
public async Task<string> GetCountries()
{
var client = new RestClient("http://api.xplorpal.com");
var request = new RestRequest("/countries", Method.POST);
var response = await client.ExecuteTaskAsync(request);
var content = response.Content;
var responseCountries = JsonConvert.DeserializeObject<IEnumerable<GettingCountry.RootObjectCountries>>(content);
GettingCountry.CountriesList.Clear();
GettingCountry.ListOfCountriesRoot.Clear();
foreach (var country in responseCountries)
{
GettingCountry.CountriesList.Add(country.nicename);
GettingCountry.ListOfCountriesRoot.Add(new GettingCountry.RootObjectCountries(country.id, country.nicename));
}
return content;
}
}
After this I need to call method of this class somewhere, like this for example var countries_list = await GettingCountries.GetCountries();
But now I have error.
How I can solve it? I can make it static, but is this ok? Maybe smth other?