package id.iiyh.inatrading.feature.news.data.model

import com.google.gson.annotations.SerializedName

data class NewsArticle(
    val id: String,
    val title: String,
    val subtitle: String? = null,
    val summary: String? = null,
    val category: String? = null,
    val reporter: String? = null,
    val section1: String? = null,
    val section2: String? = null,
    val section3: String? = null,
    val image1: String? = null,
    val image2: String? = null,
    val image3: String? = null,
    val image4: String? = null,
    val image5: String? = null,
) {
    /** summary jika ada, fallback ke subtitle */
    val displaySummary: String get() = summary?.takeIf { it.isNotBlank() } ?: subtitle.orEmpty()

    /** Semua gambar yang tidak null */
    val images: List<String> get() = listOfNotNull(image1, image2, image3, image4, image5)
}

data class NewsListResponse(
    val responseCode: String? = null,
    val responseDesc: String? = null,
    val rows: List<NewsArticle> = emptyList(),
    val totalItem: Int = 0,
    val totalPage: Int = 0,
) {
    val isSuccess: Boolean get() = responseCode == "0000"
}
