private KanyeQuoteModel getKanyeQuote() { var mockKanyeQuote = new KanyeQuoteModel { Quote = "I aint saying shes a golddigger" }; return(mockKanyeQuote); }
public void Run() { string content = string.Empty; string kanyeQuoteUrl = @"https://api.kanye.rest/"; using (var wc = new WebClient()) { content = wc.DownloadString(kanyeQuoteUrl); } KanyeQuoteModel kanyeQuote = JsonSerializer.Deserialize <KanyeQuoteModel>(content); Console.WriteLine($"\n{kanyeQuote.Quote}"); Console.WriteLine(); }
public void Run() { string content = string.Empty; string kanyeQuoteUrl = @"https://api.kanye.rest/"; KanyeQuoteModel kanyeQuote = new KanyeQuoteModel(); try { using (var wc = GetWebClient()) { content = wc.DownloadString(kanyeQuoteUrl); } kanyeQuote = kanyeQuote = JsonSerializer.Deserialize <KanyeQuoteModel>(content); } catch { Console.WriteLine("Got no result or couldn't convert to an insightful Yeezy meme"); } Console.WriteLine($"\n{kanyeQuote?.Quote}"); Console.WriteLine(); }