package com.rssuper.models

import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverters
import com.rssuper.converters.DateConverter
import com.rssuper.converters.FeedItemListConverter
import kotlinx.parcelize.Parcelize
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.util.Date

@JsonClass(generateAdapter = true)
@Parcelize
@TypeConverters(DateConverter::class, FeedItemListConverter::class)
@Entity(tableName = "feeds")
data class Feed(
    @PrimaryKey
    val id: String,
    
    @Json(name = "title")
    val title: String,
    
    @Json(name = "link")
    val link: String? = null,
    
    @Json(name = "description")
    val description: String? = null,
    
    @Json(name = "subtitle")
    val subtitle: String? = null,
    
    @Json(name = "language")
    val language: String? = null,
    
    @Json(name = "lastBuildDate")
    val lastBuildDate: Date? = null,
    
    @Json(name = "updated")
    val updated: Date? = null,
    
    @Json(name = "generator")
    val generator: String? = null,
    
    @Json(name = "ttl")
    val ttl: Int? = null,
    
    @Json(name = "items")
    val items: List<FeedItem> = emptyList(),
    
    @Json(name = "rawUrl")
    val rawUrl: String,
    
    @Json(name = "lastFetchedAt")
    val lastFetchedAt: Date? = null,
    
    @Json(name = "nextFetchAt")
    val nextFetchAt: Date? = null
) : Parcelable
