package com.sambath.kunkhmer.remote

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

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

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

@JsonClass(generateAdapter = true)
data class ProductInfo(
    @Json(name = "_id")
    val productId: String,
    @Json(name = "price")
    val price: Int,
    @Json(name = "name")
    val name: String,
    @Json(name = "desc")
    val desc: String,
    @Json(name = "createdAt")
    val createdAt: String,
    @Json(name = "filename")
    val filename: String? = null,
)

///////

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

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

@JsonClass(generateAdapter = true)
data class ProductCreatedData(
    @Json(name = "product")
    val obj: CreatedProduct,
)

@JsonClass(generateAdapter = true)
data class CreatedProduct(
    @Json(name = "_id")
    val id: String,
    @Json(name = "price")
    val price: Int,
    @Json(name = "name")
    val name: 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,
)