public IList <string> GetCategories() { var client = new ChuckNorrisHttpClient(new Uri(URL)); var response = client.GetStringAsync(new Uri($"/jokes/categories", UriKind.Relative)).Result; JArray categories = JsonConvert.DeserializeObject <JArray>(response); List <string> retval = new List <string>(categories.Count); foreach (JToken cat in categories) { retval.Add(cat.ToString()); } return(retval); }
public virtual IList <string> GetJokes(JokeRequest jokeRequest) { var client = new ChuckNorrisHttpClient(new Uri(URL)); string qs = BuildQueryString(jokeRequest, client); List <string> jokes = new List <string>(jokeRequest.JokeCount); //Set that capacity like a boss for (int i = 0; i < jokeRequest.JokeCount; i++) { var response = client.GetStringAsync(new Uri($"/jokes/random{qs}", UriKind.Relative)).Result; var joke = JsonConvert.DeserializeObject <ChuckNorrisHttpResponseJoke>(response).value; jokes.Add(joke); } return(jokes); }