-
-
Save cleftheris/110654b22bcd979f9232dc891bfd07cc to your computer and use it in GitHub Desktop.
QuoteOfTheDayTask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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