diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java index a87079d5a..f75f72a76 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java @@ -1,17 +1,16 @@ package me.chanjar.weixin.cp.api; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; import lombok.NonNull; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.external.*; import me.chanjar.weixin.cp.bean.external.contact.*; -import me.chanjar.weixin.cp.bean.oa.WxCpApprovalInfoQueryFilter; import org.jetbrains.annotations.NotNull; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.Date; import java.util.List; @@ -977,7 +976,8 @@ public interface WxCpExternalContactService { * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_intercept_rule?access_token=ACCESS_TOKEN *
*/
- WxCpInterceptRuleResultResp updateInterceptRule(WxCpInterceptRuleResp ruleResp) throws WxErrorException;
+ WxCpInterceptRuleResultResp updateInterceptRule(WxCpInterceptRuleResp ruleResp) throws WxErrorException;
+
/**
*
* 删除敏感词规则
@@ -987,6 +987,42 @@ public interface WxCpExternalContactService {
*
* @param rule_id 规则id
*/
- WxCpBaseResp delInterceptRule(String rule_id) throws WxErrorException;
+ WxCpBaseResp delInterceptRule(String rule_id) throws WxErrorException;
+ /**
+ *
+ * 创建商品图册
+ * 企业和第三方应用可以通过此接口增加商品
+ * 请求方式:POST(HTTPS)
+ * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_product_album?access_token=ACCESS_TOKEN
+ * 文档地址:https://developer.work.weixin.qq.com/document/path/95096#%E5%88%9B%E5%BB%BA%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C
+ *
+ * @param wxCpProductAlbumInfo 商品图册信息
+ * @return 商品id
+ */
+ String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException;
+
+ /**
+ *
+ * 编辑商品图册
+ * 企业和第三方应用可以通过此接口修改商品信息
+ * 请求方式:POST(HTTPS)
+ * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/update_product_album?access_token=ACCESS_TOKEN
+ * 文档地址:https://developer.work.weixin.qq.com/document/path/95096#%E7%BC%96%E8%BE%91%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C
+ *
+ * @param wxCpProductAlbumInfo 商品图册信息
+ */
+ void updateProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException;
+
+ /**
+ *
+ * 删除商品图册
+ * 企业和第三方应用可以通过此接口删除商品信息
+ * 请求方式:POST(HTTPS)
+ * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/delete_product_album?access_token=ACCESS_TOKEN
+ * 文档地址:https://developer.work.weixin.qq.com/document/path/95096#%E5%88%A0%E9%99%A4%E5%95%86%E5%93%81%E5%9B%BE%E5%86%8C
+ *
+ * @param productId 商品id
+ */
+ void deleteProductAlbum(String productId) throws WxErrorException;
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java
index 89fc6961d..bfd5608ed 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java
@@ -2,12 +2,6 @@ package me.chanjar.weixin.cp.api.impl;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.UUID;
-
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
@@ -27,9 +21,13 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.UUID;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.*;
@@ -857,10 +855,32 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
@Override
public WxCpBaseResp delInterceptRule(String rule_id) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
- jsonObject.addProperty("rule_id",rule_id);
+ jsonObject.addProperty("rule_id", rule_id);
return WxCpBaseResp
.fromJson(this.mainService.post(this.mainService.getWxCpConfigStorage().getApiUrl(DEL_INTERCEPT_RULE), jsonObject));
}
+ @Override
+ public String addProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException {
+ String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_PRODUCT_ALBUM);
+ String responseContent = this.mainService.post(url, wxCpProductAlbumInfo.toJson());
+ JsonObject tmpJson = GsonParser.parse(responseContent);
+ return tmpJson.get("product_id").getAsString();
+ }
+
+ @Override
+ public void updateProductAlbum(WxCpProductAlbumInfo wxCpProductAlbumInfo) throws WxErrorException {
+ String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_PRODUCT_ALBUM);
+ this.mainService.post(url, wxCpProductAlbumInfo.toJson());
+ }
+
+ @Override
+ public void deleteProductAlbum(String productId) throws WxErrorException {
+ JsonObject o = new JsonObject();
+ o.addProperty("product_id", productId);
+ String url = this.mainService.getWxCpConfigStorage().getApiUrl(DELETE_PRODUCT_ALBUM);
+ this.mainService.post(url, o.toString());
+ }
+
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumInfo.java
index e0ad62ea3..c837d3085 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumInfo.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpProductAlbumInfo.java
@@ -50,4 +50,8 @@ public class WxCpProductAlbumInfo implements Serializable {
return WxCpGsonBuilder.create().fromJson(json, WxCpProductAlbumInfo.class);
}
+ public String toJson() {
+ return WxCpGsonBuilder.create().toJson(this);
+ }
+
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java
index c3b4e03ec..71a6d0345 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java
@@ -273,8 +273,12 @@ public interface WxCpApiPathConsts {
String GET_GROUP_MSG_LIST_V2 = "/cgi-bin/externalcontact/get_groupmsg_list_v2";
String GET_GROUP_MSG_RESULT = "/cgi-bin/externalcontact/get_group_msg_result";
+
String GET_PRODUCT_ALBUM = "/cgi-bin/externalcontact/get_product_album";
String GET_PRODUCT_ALBUM_LIST = "/cgi-bin/externalcontact/get_product_album_list";
+ String ADD_PRODUCT_ALBUM = "/cgi-bin/externalcontact/add_product_album";
+ String UPDATE_PRODUCT_ALBUM = "/cgi-bin/externalcontact/update_product_album";
+ String DELETE_PRODUCT_ALBUM = "/cgi-bin/externalcontact/delete_product_album";
String GROUP_WELCOME_TEMPLATE_ADD = "/cgi-bin/externalcontact/group_welcome_template/add";
String GROUP_WELCOME_TEMPLATE_EDIT = "/cgi-bin/externalcontact/group_welcome_template/edit";