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.UriIntent;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 小米
 *
 * @author yanglin
 */
@Component
@RequiredArgsConstructor
class XMPushPayloadBuilder extends AndroidPushPayloadBuilder<UriIntent> {

    private final PushProps pushProps;

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

    @Override
    public void build(PushContent content, UriIntent intent, JSONObject payload) {
        PushProps.ChannelConfig xmCfg = pushProps.getXiaomiChannelConfig();
        payload.put("channel_id", content.determineChannelId(xmCfg));
        payload.put("notify_foreground", "1");
        payload.put("notify_effect", "2");
        payload.put("intent_uri", intent.build());
    }

}