Skip to content

Commit

Permalink
Merge pull request #15 from NotFound403/1.2.3.dev
Browse files Browse the repository at this point in the history
1.2.3
  • Loading branch information
NotFound403 authored Nov 2, 2023
2 parents 5cec925 + 1cbb91b commit 28deb99
Show file tree
Hide file tree
Showing 61 changed files with 1,940 additions and 209 deletions.
181 changes: 0 additions & 181 deletions QUICKSTART.md

This file was deleted.

4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>cn.felord</groupId>
<artifactId>wecom</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
<packaging>pom</packaging>

<name>wecom</name>
Expand Down Expand Up @@ -107,7 +107,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<retrofit.version>2.9.0</retrofit.version>
<okhttp3.version>4.11.0</okhttp3.version>
<okhttp3.version>4.12.0</okhttp3.version>
<jackson.version>2.15.2</jackson.version>
<xstream.version>1.4.20</xstream.version>
<jose.version>9.36</jose.version>
Expand Down
2 changes: 1 addition & 1 deletion rx-wecom-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>cn.felord</groupId>
<artifactId>wecom</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>
<artifactId>rx-wecom-sdk</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,38 @@
package cn.felord.reactive.api;

import cn.felord.AgentDetails;
import cn.felord.WeComException;
import cn.felord.domain.GenericResponse;
import cn.felord.domain.WeComResponse;
import cn.felord.domain.agent.AgentDetailsResponse;
import cn.felord.domain.agent.AgentMenuBtn;
import cn.felord.domain.agent.AgentMenuBtns;
import cn.felord.domain.agent.AgentSettingRequest;
import cn.felord.domain.agent.Image;
import cn.felord.domain.agent.ImageWorkbenchTemplate;
import cn.felord.domain.agent.Items;
import cn.felord.domain.agent.KeyData;
import cn.felord.domain.agent.KeyDataWorkbenchTemplate;
import cn.felord.domain.agent.ListWorkbenchTemplate;
import cn.felord.domain.agent.UserImageWorkbenchTemplate;
import cn.felord.domain.agent.UserKeyDataWorkbenchTemplate;
import cn.felord.domain.agent.UserListWorkbenchTemplate;
import cn.felord.domain.agent.UserWebviewWorkbenchTemplate;
import cn.felord.domain.agent.UserWorkBenchSetting;
import cn.felord.domain.agent.UserWorkbenchTemplate;
import cn.felord.domain.agent.Webview;
import cn.felord.domain.agent.WebviewWorkbenchTemplate;
import cn.felord.domain.agent.WorkBenchSetting;
import cn.felord.domain.agent.WorkbenchDetailResponse;
import cn.felord.domain.agent.WorkbenchTemplate;
import cn.felord.enumeration.WorkbenchType;
import io.reactivex.rxjava3.core.Single;
import retrofit2.Retrofit;
import retrofit2.http.Body;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* The type Agent manager api.
Expand All @@ -43,7 +70,6 @@ public class AgentManagerApi {
this.agentDetails = agentDetails;
}


/**
* Gets agent details.
*
Expand All @@ -64,6 +90,101 @@ public Single<WeComResponse> settings(AgentSettingRequest request) {
}


/**
* 创建菜单
*
* @param request the request
* @return the we com response @ the we com exception
*/
public Single<WeComResponse> createMenu(AgentMenuBtns request) {
return internalAgentManagerApi.createMenu(agentDetails.getAgentId(), request);
}

/**
* 获取菜单
*
* @return the menu @ the we com exception
*/
public Single<GenericResponse<List<AgentMenuBtn>>> getMenu() {
return internalAgentManagerApi.getMenu(agentDetails.getAgentId());
}

/**
* 删除菜单
*
* @return the we com response @ the we com exception
*/
public Single<WeComResponse> deleteMenu() {
return internalAgentManagerApi.deleteMenu(agentDetails.getAgentId());
}

/**
* 设置应用在工作台展示的模版
* <p>
* 该接口指定应用自定义模版类型。同时也支持设置企业默认模版数据。若type指定为 "normal" 则为取消自定义模式,改为普通展示模式
*
* @param setting the setting
* @return the workbench template @ the we com exception
*/
public Single<WeComResponse> setWorkbenchTemplate(WorkBenchSetting<?> setting) {

String agentId = agentDetails.getAgentId();
boolean replaceUserData = setting.isReplaceUserData();
WorkbenchTemplate template = WorkbenchTemplate.normal(agentId, replaceUserData);
WorkbenchType type = setting.getType();

if (Objects.equals(WorkbenchType.KEY_DATA, type)) {
template = new KeyDataWorkbenchTemplate(agentId, replaceUserData, (KeyData) setting.getBody());
} else if (Objects.equals(WorkbenchType.IMAGE, type)) {
template = new ImageWorkbenchTemplate(agentId, replaceUserData, (Image) setting.getBody());
} else if (Objects.equals(WorkbenchType.LIST, type)) {
template = new ListWorkbenchTemplate(agentId, replaceUserData, (Items) setting.getBody());
} else if (Objects.equals(WorkbenchType.WEBVIEW, type)) {
template = new WebviewWorkbenchTemplate(agentId, replaceUserData, (Webview) setting.getBody());
}
return internalAgentManagerApi.setWorkbenchTemplate(template);
}

/**
* 获取应用在工作台展示的模版
*
* @return the workbench template @ the we com exception
*/
public Single<WorkbenchDetailResponse> getWorkbenchTemplate() {
return internalAgentManagerApi.getWorkbenchTemplate(Collections.singletonMap("agentid", agentDetails.getAgentId()));
}


/**
* 设置应用在用户工作台展示的数据
* <p>
* 可设置当前凭证对应的应用;设置的userid必须在应用可见范围;
* 每个用户每个应用接口限制10次/分钟;
*
* @param userSetting the user setting
* @return the workbench data @ the we com exception
*/
public Single<WeComResponse> setWorkbenchData(@Body UserWorkBenchSetting<?> userSetting) {
String agentId = agentDetails.getAgentId();
String userid = userSetting.getUserid();
UserWorkbenchTemplate template;
WorkbenchType type = userSetting.getType();

if (Objects.equals(WorkbenchType.KEY_DATA, type)) {
template = new UserKeyDataWorkbenchTemplate(agentId, userid, (KeyData) userSetting.getBody());
} else if (Objects.equals(WorkbenchType.IMAGE, type)) {
template = new UserImageWorkbenchTemplate(agentId, userid, (Image) userSetting.getBody());
} else if (Objects.equals(WorkbenchType.LIST, type)) {
template = new UserListWorkbenchTemplate(agentId, userid, (Items) userSetting.getBody());
} else if (Objects.equals(WorkbenchType.WEBVIEW, type)) {
template = new UserWebviewWorkbenchTemplate(agentId, userid, (Webview) userSetting.getBody());
} else {
throw new WeComException("invalid workbench type");
}

return internalAgentManagerApi.setWorkbenchData(template);
}

/**
* The type Settings.
*/
Expand Down
Loading

0 comments on commit 28deb99

Please sign in to comment.