All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.chanjar.weixin.cp.bean.messagebuilder.MpnewsBuilder Maven / Gradle / Ivy

There is a newer version: 4.6.7.B
Show newest version
package me.chanjar.weixin.cp.bean.messagebuilder;

import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.cp.bean.article.MpnewsArticle;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;

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

/**
 * mpnews类型的图文消息builder
 * 
 * 用法:
 * WxCustomMessage m = WxCustomMessage.MPNEWS().addArticle(article).toUser(...).build();
 * 
* * @author Binary Wang */ public final class MpnewsBuilder extends BaseBuilder { private List articles = new ArrayList<>(); private String mediaId; /** * Instantiates a new Mpnews builder. */ public MpnewsBuilder() { this.msgType = WxConsts.KefuMsgType.MPNEWS; } /** * Media id mpnews builder. * * @param mediaId the media id * @return the mpnews builder */ public MpnewsBuilder mediaId(String mediaId) { this.mediaId = mediaId; return this; } /** * Add article mpnews builder. * * @param articles the articles * @return the mpnews builder */ public MpnewsBuilder addArticle(MpnewsArticle... articles) { Collections.addAll(this.articles, articles); return this; } /** * Articles mpnews builder. * * @param articles the articles * @return the mpnews builder */ public MpnewsBuilder articles(List articles) { this.articles = articles; return this; } @Override public WxCpMessage build() { WxCpMessage m = super.build(); m.setMpnewsArticles(this.articles); if (this.mediaId != null) { m.setMediaId(this.mediaId); } return m; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy