package com.sambath.kunkhmer.remote

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class NewsResponse(
    @Json(name = "code")
    val resultCode: Int,
    @Json(name = "message")
    val message: ResponseMessage,
    @Json(name = "data")
    val data: NewsData?
)

@JsonClass(generateAdapter = true)
data class NewsData(
    @Json(name = "object")
    val obj: MutableList<News>,
)

@JsonClass(generateAdapter = true)
data class News(
    @Json(name = "_id")
    val id: String,
    @Json(name = "viewer")
    val viewer: Int,
    @Json(name = "title")
    val title: String,
    @Json(name = "desc")
    val desc: String,
    @Json(name = "createdAt")
    val createdAt: String,
    @Json(name = "filename")
    val filename: String?,
)

// ---- create request

@JsonClass(generateAdapter = true)
class CreateNewsRequest(
    @Json(name = "title")
    val title: String,
    @Json(name = "desc")
    val desc: String,
    @Json(name = "upload")
    val upload: String
)

@JsonClass(generateAdapter = true)
data class CreateNewsResponse(
    @Json(name = "code")
    val resultCode: Int,
    @Json(name = "message")
    val message: ResponseMessage,
    @Json(name = "data")
    val data: NewsCreatedData?
)

@JsonClass(generateAdapter = true)
data class NewsCreatedData(
    @Json(name = "new")
    val obj: CreatedNews,
)

@JsonClass(generateAdapter = true)
data class CreatedNews(
    @Json(name = "_id")
    val id: String,
    @Json(name = "viewer")
    val viewer: Int,
    @Json(name = "title")
    val title: String,
    @Json(name = "desc")
    val desc: String,
    @Json(name = "createdAt")
    val createdAt: String,
    @Json(name = "updatedAt")
    val updatedAt: String,
    @Json(name = "__v")
    val _v: Int,
)