Skip to content

Instantly share code, notes, and snippets.

@cleftheris
Created September 19, 2017 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleftheris/110654b22bcd979f9232dc891bfd07cc to your computer and use it in GitHub Desktop.
Save cleftheris/110654b22bcd979f9232dc891bfd07cc to your computer and use it in GitHub Desktop.
QuoteOfTheDayTask
// uses https://theysaidso.com/api/
public class QuoteOfTheDayTask : IScheduledTask
{
public string Schedule => "* */6 * * *";
public async Task Invoke(CancellationToken cancellationToken)
{
var httpClient = new HttpClient();
var quoteJson = JObject.Parse(await httpClient.GetStringAsync("http://quotes.rest/qod.json"));
QuoteOfTheDay.Current = JsonConvert.DeserializeObject<QuoteOfTheDay>(quoteJson["contents"]["quotes"][0].ToString());
}
}
public class QuoteOfTheDay
{
public static QuoteOfTheDay Current { get; set; }
static QuoteOfTheDay()
{
Current = new QuoteOfTheDay { Quote = "No quote", Author = "Maarten" };
}
public string Quote { get; set; }
public string Author { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment