package com.xplora.contactprovider.dao

import androidx.annotation.NonNull
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
import com.xplora.contactprovider.provider.WatchContactProvider.Companion.TABLE_NAME_CONTACT


@Entity(tableName = TABLE_NAME_CONTACT, indices = [Index(value = ["_id"], unique = true)])
data class ContactInfo(
    @PrimaryKey(autoGenerate = true)
    @NonNull
    @SerializedName("_id")
    var _id: Long,
    /**
     * Guardian's ID of contact. contact's resource ID
     */
    @SerializedName("id")
    var id: String? = null,
    @SerializedName("userId")
    var userId: String? = null,
    @SerializedName("name")
    var name: String? = null,
    /**
     *  profile image url
     */
    @SerializedName("profile")
    var profile: String? = null,
    /**
     *  phone number(without country phone number)
     */
    @SerializedName("phoneNumber")
    var phoneNumber: String? = null,
    /**
     * Country phone number
     */
    @SerializedName("countryPN")
    var countryPN: String? = null,
    /**
     * SIM type. Reserved column.
     * - 1 : DATA SIM
     * - 2 : DATA + Voice SIM
     * - 100 : Unknown.
     */
    @SerializedName("sim")
    var sim: String? = null,
    /**
     * - 1 : First guardian(SOS target)
     * - 2 : Second guardian
     * - 3 : General contact(Not member of XPLORA server)
     * - 4 : Friend
     */
    @SerializedName("type")
    var type: String? = null,
    @SerializedName("rate")
    var rate: String? = null,
    @SerializedName("unRead")
    var unRead: String? = null,
    @SerializedName("profilePath")
    var profilePath: String? = null
) {
    fun merge(other: ContactInfo) {
        id = other.id ?: id
        userId = other.userId ?: userId
        name = other.name ?: name
        profile = other.profile ?: profile
        phoneNumber = other.phoneNumber ?: phoneNumber
        countryPN = other.countryPN ?: countryPN
        sim = other.sim ?: sim
        type = other.type ?: type
        rate = other.rate ?: rate
        unRead = other.unRead ?: unRead
        profilePath = other.profilePath ?: profilePath
    }
}