package fr.teamflash.fencerjudgeback.websocket.models

import fr.teamflash.fencerjudgeback.entities.RefereeBean
import fr.teamflash.fencerjudgeback.entities.RefereeLevel

/**
 * Message model for referee updates sent through WebSocket
 */
data class RefereeUpdateMessage(
    val refereeId: Long,
    val name: String?,
    val firstName: String?,
    val level: RefereeLevel?,
    val type: UpdateType = UpdateType.REFEREE_UPDATE
) {
    enum class UpdateType {
        REFEREE_UPDATE,
        REFEREE_CREATE,
        REFEREE_DELETE
    }
    
    companion object {
        /**
         * Create a RefereeUpdateMessage from a RefereeBean
         */
        fun fromRefereeBean(refereeBean: RefereeBean, type: UpdateType = UpdateType.REFEREE_UPDATE): RefereeUpdateMessage {
            return RefereeUpdateMessage(
                refereeId = refereeBean.id ?: 0,
                name = refereeBean.name,
                firstName = refereeBean.firstName,
                level = refereeBean.level,
                type = type
            )
        }
    }
}