/// <summary> /// Get a random joke(s) wrapper method, retrieves chuck norris jokes. /// </summary> /// <param name="category">The category of Chuck Norris jokes we want.</param> /// <param name="number">The number of Chuck Norris jokes we want.</param> private static void GetRandomJokes(string category, int numberOfResults) { var args = new Dictionary <String, String>(); if (category != null) { if (GetCategories().Contains(category)) { args.Add("category", category); } } if (name != null) { args.Add("name", name); } if (category == null && name == null) { args = null; } _jsonFeed = new JsonFeed(ChuckNorisJokesURL, numberOfResults, "value"); results = _jsonFeed.GetJSONValuesList(ChuckNorrisRandomJokesResource, args).ToArray(); }
/// <summary> /// Get the categories wrapper method, retrieves the categories of Chuck Norris jokes. /// </summary> /// <returns>Returns a string list of categories for Chuck Norris jokes.</returns> private static List <String> GetCategories() { _jsonFeed = new JsonFeed(ChuckNorisJokesURL, 0); List <String> categories = _jsonFeed.GetJSONValuesList(ChuckNorrisCategoryResource); results = categories.ToArray(); return(categories); }
/// <summary> /// Get the name wrapper method, retrieve a random name to replace Chuck Norris with. /// </summary> private static void GetNames() { _jsonFeed = new JsonFeed(RandomNamesSiteURL, 0); name = _jsonFeed.GetJSONValuesList()[0]; }
public JokeCheckService(ILogger <JokeCheckService> logger, IJsonFeed feed) { _logger = logger; _feed = feed; }