public class Api
{
public const string apiUrl = "http://j...content-available-to-author-only...e.com/photos";
public async Task<IEnumerable<Photo>> GetPhotosAsync()
{
using HttpClient http = new HttpClient();
using var response = await http.GetAsync(apiUrl);
if(response.IsSuccessStatusCode)
{
string json = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<IEnumerable<Photo>>(json);
}
return Array.Empty<Photo>();
}
}
public class Photo
{
public int AlbumId { get; set; }
public int Id { get; set; }
public string Title { get; set; }
public string Url { get; set; }
public string ThumbnailUrl { get; set; }
}