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.StringListConverter
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, StringListConverter::class)
@Entity(tableName = "feed_items")
data class FeedItem(
    @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 = "content")
    val content: String? = null,
    
    @Json(name = "author")
    val author: String? = null,
    
    @Json(name = "published")
    val published: Date? = null,
    
    @Json(name = "updated")
    val updated: Date? = null,
    
    @Json(name = "categories")
    val categories: List<String>? = null,
    
    @Json(name = "enclosure")
    val enclosure: Enclosure? = null,
    
    @Json(name = "guid")
    val guid: String? = null,
    
    @Json(name = "subscriptionTitle")
    val subscriptionTitle: String? = null
) : Parcelable

@JsonClass(generateAdapter = true)
@Parcelize
data class Enclosure(
    @Json(name = "url")
    val url: String,
    
    @Json(name = "type")
    val type: String,
    
    @Json(name = "length")
    val length: Long? = null
) : Parcelable
