package com.adealink.weparty.im.session.mesasge

import com.adealink.frame.aab.util.getCompatString
import com.adealink.frame.data.json.froJsonErrorNull
import com.adealink.weparty.im.R
import com.adealink.weparty.module.order.data.PlaymateOrderData
import com.tencent.imsdk.v2.V2TIMMessage
import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean
import com.tencent.qcloud.tuikit.timcommon.bean.TUIReplyQuoteBean
import com.tencent.qcloud.tuikit.tuichat.bean.message.reply.TextReplyQuoteBean

class PlaymateOrderMessageBean : TUIMessageBean() {

    var data: PlaymateOrderData? = null
    override fun onGetDisplayString(): String? {
        return getCompatString(R.string.im_playmate_order_title)
    }

    override fun onProcessMessage(v2TIMMessage: V2TIMMessage) {
        val byte = v2TIMMessage.customElem?.data ?: return
        val dataStr = String(byte)
        val playmateData = froJsonErrorNull<PlaymateOrderData>(dataStr)
        //填充数据
        this.data = playmateData
    }

    override fun getReplyQuoteBeanClass(): Class<out TUIReplyQuoteBean<*>?> {
        return TextReplyQuoteBean::class.java
    }
}
