package com.ematou.wxservice.common.xml.builder;

import com.ematou.wxservice.mp.message.WeChatMpXmlOutNewsMessage;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author lhm
 * @version 1.0
 * 2021-05-12 11:52
 */
public class NewsBuilder extends BaseBuilder<NewsBuilder, WeChatMpXmlOutNewsMessage> {

    private List<WeChatMpXmlOutNewsMessage.Item> articles = new ArrayList<>();

    public NewsBuilder addArticle(WeChatMpXmlOutNewsMessage.Item... items) {
        Collections.addAll(this.articles, items);
        return this;
    }

    public NewsBuilder articles(List<WeChatMpXmlOutNewsMessage.Item> articles){
        this.articles = articles;
        return this;
    }

    @Override
    public WeChatMpXmlOutNewsMessage build() {
        WeChatMpXmlOutNewsMessage m = new WeChatMpXmlOutNewsMessage();
        for (WeChatMpXmlOutNewsMessage.Item item : this.articles) {
            m.addArticle(item);
        }
        setCommon(m);
        return m;
    }

    public String XMLmsg(String msg){
        return msg;
    }

}
