package com.carmaintenance.data.model

import com.google.gson.annotations.SerializedName

/**
 * 预约实体
 */
data class Appointment(
    @SerializedName("appointmentId")
    val appointmentId: Int,
    @SerializedName("customerId")
    val customerId: Int,
    @SerializedName("vehicleId")
    val vehicleId: Int,
    @SerializedName("serviceType")
    val serviceType: String,
    @SerializedName("appointmentTime")
    val appointmentTime: String,
    @SerializedName("contactPhone")
    val contactPhone: String,
    @SerializedName("description")
    val description: String? = null,
    @SerializedName("status")
    val status: String,
    @SerializedName("createTime")
    val createTime: String
) {
    enum class Status(val displayName: String) {
        PENDING("待确认"),
        CONFIRMED("已确认"),
        COMPLETED("已完成"),
        CANCELLED("已取消");

        companion object {
            fun fromValue(value: String): Status {
                return values().find { it.name.lowercase() == value } ?: PENDING
            }
        }
    }

    val statusEnum: Status
        get() = Status.fromValue(status)
}
