package com.tencent.qcloud.tuikit.tuichat.bean.message;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.tencent.imsdk.v2.V2TIMMessage;

import java.util.HashMap;

/**
 * @Description: java类作用描述
 * @Author: lidandan
 * @CreateDate: 2021/12/31 6:34 下午
 */
public class ChatGiftMessageBean extends TUIMessageBean {

    private String giftUrl;

    public String getGiftUrl() {
        return giftUrl;
    }

    @Override
    public String onGetDisplayString() {
        return giftUrl;
    }

    @Override
    public void onProcessMessage(V2TIMMessage v2TIMMessage) {
        giftUrl = "";
        String data = new String(v2TIMMessage.getCustomElem().getData());
        try {
            HashMap map = new Gson().fromJson(data, HashMap.class);
            if (map != null) {
                giftUrl = (String) map.get("giftUrl");
            }
        } catch (JsonSyntaxException e) {

        }
        setExtra(giftUrl);
    }
}
