part of fever_api;

class Feed {
  final FeverAPI api;

  late int id;
  late int faviconId;
  late String title;
  late String url;
  late String siteUrl;
  late bool isSpark;
  late DateTime lastUpdatedOnTime;

  Feed(this.api, {
    required this.id,
    required this.faviconId,
    required this.title,
    required this.url,
    required this.siteUrl,
    required this.isSpark,
    required this.lastUpdatedOnTime,
  });

  Feed.fromJSON(this.api, Map<String, dynamic> json) {
    id = toInt(json['id']);
    faviconId = toInt(json['favicon_id']);
    title = json['title'];
    url = json['url'];
    siteUrl = json['site_url'];
    isSpark = json['isSpark'] == 1;
    lastUpdatedOnTime = DateTime.fromMillisecondsSinceEpoch(toInt(json['last_updated_on_time']) * 1000);
  }

  @override
  String toString() {
    return 'Feed $id: $title';
  }
}
