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 kotlinx.parcelize.Parcelize
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.util.Date

@JsonClass(generateAdapter = true)
@Parcelize
@TypeConverters(DateConverter::class)
@Entity(tableName = "feed_subscriptions")
data class FeedSubscription(
    @PrimaryKey
    val id: String,
    
    @Json(name = "url")
    val url: String,
    
    @Json(name = "title")
    val title: String,
    
    @Json(name = "category")
    val category: String? = null,
    
    @Json(name = "enabled")
    val enabled: Boolean = true,
    
    @Json(name = "fetchInterval")
    val fetchInterval: Long,
    
    @Json(name = "createdAt")
    val createdAt: Date,
    
    @Json(name = "updatedAt")
    val updatedAt: Date,
    
    @Json(name = "lastFetchedAt")
    val lastFetchedAt: Date? = null,
    
    @Json(name = "nextFetchAt")
    val nextFetchAt: Date? = null,
    
    @Json(name = "error")
    val error: String? = null,
    
    @Json(name = "httpAuth")
    val httpAuth: HttpAuth? = null
) : Parcelable

@JsonClass(generateAdapter = true)
@Parcelize
data class HttpAuth(
    @Json(name = "username")
    val username: String,
    
    @Json(name = "password")
    val password: String
) : Parcelable
