Rename NoticeApi to TokenManagerApi, and use it in QrCodeApi too.
This commit is contained in:
parent
1241072a1b
commit
977ccae14f
@ -20,12 +20,10 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/api/qrcode.html">获取二维码</a>
|
||||
* @since 1.8
|
||||
*/
|
||||
public class QrCodeApi extends WxaApi {
|
||||
|
||||
private final TokenManager tokenManager;
|
||||
public class QrCodeApi extends TokenManagerApi {
|
||||
|
||||
public QrCodeApi(TokenManager tokenManager) {
|
||||
this.tokenManager = tokenManager;
|
||||
super(tokenManager);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,8 +52,7 @@ public class QrCodeApi extends WxaApi {
|
||||
Color lineColor,
|
||||
Boolean hyaline
|
||||
) throws WeixinException {
|
||||
final String accessToken = tokenManager.getAccessToken();
|
||||
final String getWxaCodeUri = this.getRequestUri("wxa_getwxacode", accessToken);
|
||||
final String getWxaCodeUri = this.getAccessTokenRequestUri("wxa_getwxacode");
|
||||
final WxaCodeParameter param = new WxaCodeParameter(path, width, autoColor, lineColor, hyaline);
|
||||
return this.postAsImageBytes(getWxaCodeUri, param);
|
||||
}
|
||||
@ -105,8 +102,7 @@ public class QrCodeApi extends WxaApi {
|
||||
Color lineColor,
|
||||
Boolean hyaline
|
||||
) throws WeixinException {
|
||||
final String accessToken = tokenManager.getAccessToken();
|
||||
final String getWxaCodeUnlimitUri = this.getRequestUri("wxa_getwxacodeunlimit", accessToken);
|
||||
final String getWxaCodeUnlimitUri = this.getAccessTokenRequestUri("wxa_getwxacodeunlimit");
|
||||
final WxaCodeUnlimitParameter param = new WxaCodeUnlimitParameter(scene, page, width, autoColor, lineColor, hyaline);
|
||||
return this.postAsImageBytes(getWxaCodeUnlimitUri, param);
|
||||
}
|
||||
@ -131,8 +127,7 @@ public class QrCodeApi extends WxaApi {
|
||||
String path,
|
||||
Integer width
|
||||
) throws WeixinException {
|
||||
final String accessToken = tokenManager.getAccessToken();
|
||||
final String createWxaQrCode = this.getRequestUri("wxaapp_createwxaqrcode", accessToken);
|
||||
final String createWxaQrCode = this.getAccessTokenRequestUri("wxaapp_createwxaqrcode");
|
||||
final WxaQrCodeParameter param = new WxaQrCodeParameter(path, width);
|
||||
return this.postAsImageBytes(createWxaQrCode, param);
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import com.foxinmy.weixin4j.wxa.model.template.Template;
|
||||
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/api/notice.html#%E6%A8%A1%E7%89%88%E6%B6%88%E6%81%AF%E7%AE%A1%E7%90%86">模版消息管理</a>
|
||||
* @since 1.8
|
||||
*/
|
||||
public class TemplateApi extends NoticeApi {
|
||||
public class TemplateApi extends TokenManagerApi {
|
||||
|
||||
public TemplateApi(TokenManager tokenManager) {
|
||||
super(tokenManager);
|
||||
|
||||
@ -11,7 +11,7 @@ import com.foxinmy.weixin4j.token.TokenManager;
|
||||
* @see <a href="https://developers.weixin.qq.com/miniprogram/dev/api/notice.html#%E5%8F%91%E9%80%81%E6%A8%A1%E7%89%88%E6%B6%88%E6%81%AF">发送模版消息</a>
|
||||
* @since 1.8
|
||||
*/
|
||||
public class TemplateMessageApi extends NoticeApi {
|
||||
public class TemplateMessageApi extends TokenManagerApi {
|
||||
|
||||
public TemplateMessageApi(TokenManager tokenManager) {
|
||||
super(tokenManager);
|
||||
|
||||
@ -6,11 +6,11 @@ import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
import com.foxinmy.weixin4j.token.TokenManager;
|
||||
|
||||
abstract class NoticeApi extends WxaApi {
|
||||
abstract class TokenManagerApi extends WxaApi {
|
||||
|
||||
private final TokenManager tokenManager;
|
||||
|
||||
public NoticeApi(final TokenManager tokenManager) {
|
||||
public TokenManagerApi(final TokenManager tokenManager) {
|
||||
this.tokenManager = tokenManager;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user