using System.Diagnostics;
using System.Xml.Linq;
namespace NzbDrone.Core.MetadataSource.Goodreads
{
///
/// This class models the best book in a work, as defined by the Goodreads API.
///
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public sealed class BestBookResource : GoodreadsResource
{
public override string ElementName => "best_book";
///
/// The Id of this book.
///
public long Id { get; private set; }
///
/// The title of this book.
///
public string Title { get; private set; }
///
/// The Goodreads id of the author.
///
public long AuthorId { get; private set; }
///
/// The name of the author.
///
public string AuthorName { get; private set; }
///
/// The cover image of this book.
///
public string ImageUrl { get; private set; }
public string LargeImageUrl { get; private set; }
public override void Parse(XElement element)
{
Id = element.ElementAsLong("id");
Title = element.ElementAsString("title");
var authorElement = element.Element("author");
if (authorElement != null)
{
AuthorId = authorElement.ElementAsLong("id");
AuthorName = authorElement.ElementAsString("name");
}
ImageUrl = element.ElementAsString("image_url");
LargeImageUrl = element.ElementAsString("large_image_url");
}
}
}