Instantly share code, notes, and snippets.

Embed
What would you like to do?
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