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

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

/**
 * 华为
 *
 * @author yanglin
 */
@Component
class HWPushPayloadBuilder extends AndroidPushPayloadBuilder<UriIntent> {

    @Override
    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 androidConfig = new JSONObject();
        androidConfig.put("category", content.determineAndroidCategory());

        JSONObject hwField = new JSONObject();
        hwField.put("android", androidConfig);
        hwField.put("style", 1);
        hwField.put("big_title", content.getTitle());
        hwField.put("big_body", content.getContent());
        hwField.put("click_action", clickAction);

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

}