package cn.axzo.msg.center.nimpush.payload;

import cn.axzo.msg.center.nimpush.PushContent;
import cn.axzo.msg.center.nimpush.PushMessageTye;
import cn.axzo.msg.center.nimpush.payload.intent.UriIntent;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;

/**
 * 荣耀
 *
 * @author yanglin
 */
@Component
class RYPushPayloadBuilder extends AndroidPushPayloadBuilder<UriIntent> {

    @Override
    public UriIntent createIntent() {
        return new UriIntent();
    }

    @Override
    public void build(PushContent content, UriIntent intent, JSONObject payload) {
        // 点击事件的内容
        JSONObject clickAction = new JSONObject();
        clickAction.put("type", 1);
        clickAction.put("intent", intent.build());

        // 通知的内容
        JSONObject notification = new JSONObject();
        notification.put("title", content.getTitle());
        notification.put("body", content.getContent());
        notification.put("clickAction", clickAction);
        notification.put("importance",
                content.getMessageTye() == PushMessageTye.OP ? "LOW" : "NORMAL");

        JSONObject honorField = new JSONObject();
        honorField.put("notification", notification);

        payload.put("honorField", honorField);
    }

}