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

import cn.axzo.msg.center.inside.notices.config.push.PushProps;
import cn.axzo.msg.center.nimpush.PushContent;
import cn.axzo.msg.center.nimpush.payload.intent.JsonIntent;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author yanglin
 */
@Component
@RequiredArgsConstructor
class OppoPushPayloadBuilder extends AndroidPushPayloadBuilder<JsonIntent> {

    private final PushProps pushProps;

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

    @Override
    public void build(PushContent content, JsonIntent intent, JSONObject payload) {
        PushProps.ChannelConfig xmCfg = pushProps.getOppoChannelConfig();
        JSONObject oppoField = new JSONObject();
        oppoField.put("channel_id", content.determineChannelId(xmCfg));
        oppoField.put("category", content.determineAndroidCategory());
        oppoField.put("notify_level", 2);
        oppoField.put("click_action_type", 1);
        oppoField.put("click_action_activity", "com.oppo.codelabpush.intent.action.test");
        oppoField.put("action_parameters", intent.build().toJSONString());

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

}