Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 61 additions & 3 deletions client/src/main/java/cn/vika/client/api/DatasheetApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
import cn.vika.client.api.exception.ApiException;
import cn.vika.client.api.http.AbstractApi;
import cn.vika.client.api.http.ApiHttpClient;
import cn.vika.client.api.model.CreateDatasheetRequest;
import cn.vika.client.api.model.CreateDatasheetResponse;
import cn.vika.client.api.model.HttpResult;
import cn.vika.client.api.model.*;
import cn.vika.core.http.GenericTypeReference;
import cn.vika.core.http.HttpHeader;
import cn.vika.core.utils.StringUtil;

import java.util.List;

/**
* @author tao
*/
public class DatasheetApi extends AbstractApi {

private static final String POST_DATASHEET_PATH = "/spaces/%s/datasheets";

private static final String POST_EMBED_LINK_PATH = "/spaces/%s/nodes/%s/embedlinks";

private static final String GET_EMBED_LINK_PATH = "/spaces/%s/nodes/%s/embedlinks";

private static final String DELETE_EMBED_LINK_PATH = "/spaces/%s/nodes/%s/embedlinks/%s";

public DatasheetApi(ApiHttpClient apiHttpClient) {
super(apiHttpClient);
}
Expand All @@ -34,12 +40,64 @@ path, new HttpHeader(), datasheet,
return result.getData();
}

public CreateEmbedLinkResponse addEmbedLink(String spaceId, String datasheetId, CreateEmbedLinkRequest embedLink){
// check create embed link params
checkEmbedLinkPathArgs(spaceId, datasheetId);

final String path = String.format(POST_EMBED_LINK_PATH, spaceId, datasheetId);

HttpResult<CreateEmbedLinkResponse> result = getDefaultHttpClient().post(path, new HttpHeader(), embedLink,
new GenericTypeReference<HttpResult<CreateEmbedLinkResponse>>() {});
return result.getData();
}

public List<GetEmbedLinkResponse> getEmbedLink(String spaceId, String datasheetId){
// check get embed link params
checkEmbedLinkPathArgs(spaceId, datasheetId);

final String path = String.format(GET_EMBED_LINK_PATH, spaceId, datasheetId);

HttpResult<List<GetEmbedLinkResponse>> result = getDefaultHttpClient().get(path, new HttpHeader(),
new GenericTypeReference<HttpResult<List<GetEmbedLinkResponse>>>() {});

return result.getData();
}

public void deleteEmbedLink(String spaceId, String datasheetId, String embedLinkId){
// check delete embed link params
checkDeleteEmbedLinkPathArgs(spaceId, datasheetId, embedLinkId);

final String path = String.format(DELETE_EMBED_LINK_PATH, spaceId, datasheetId, embedLinkId);

getDefaultHttpClient().delete(path, new HttpHeader(), Void.class);
}


private void checkPostDatasheetPathArgs(String spaceId) {
if (!StringUtil.hasText(spaceId)) {
throw new ApiException("space id must be not null");
}
}

private void checkEmbedLinkPathArgs(String spaceId, String datasheetId) {
if (!StringUtil.hasText(spaceId)) {
throw new ApiException("space id must be not null");
}
if (!StringUtil.hasText(datasheetId)){
throw new ApiException("datasheet id must be not null");
}
}

private void checkDeleteEmbedLinkPathArgs(String spaceId, String datasheetId, String embedLinkId) {
if (!StringUtil.hasText(spaceId)) {
throw new ApiException("space id must not be null");
}
if (!StringUtil.hasText(datasheetId)) {
throw new ApiException("datasheet id must not be null");
}
if (!StringUtil.hasText(embedLinkId)) {
throw new ApiException("fieldId id must not be null");
}
}

}
14 changes: 7 additions & 7 deletions client/src/main/java/cn/vika/client/api/http/ApiHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ public DefaultHttpClient getDefaultHttpClient() {
}
}

if (callTimeout != null) {
// Sets the per request call timeout.
ClientHttpRequestFactory requestFactory = this.defaultHttpClient.getRequestFactory();
if (requestFactory instanceof OkHttpClientHttpRequestFactory) {
((OkHttpClientHttpRequestFactory) requestFactory).setCallTimeout(callTimeout);
}
}
// if (callTimeout != null) {
// // Sets the per request call timeout.
// ClientHttpRequestFactory requestFactory = this.defaultHttpClient.getRequestFactory();
// if (requestFactory instanceof OkHttpClientHttpRequestFactory) {
// ((OkHttpClientHttpRequestFactory) requestFactory).setCallTimeout(callTimeout);
// }
// }

return this.defaultHttpClient;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cn.vika.client.api.model;

public class CreateEmbedLinkRequest {

private EmbedLinkPayload payload;

private EmbedLinkThemeEnum theme;

public EmbedLinkPayload getPayload() {
return payload;
}

public void setPayload(EmbedLinkPayload payload) {
this.payload = payload;
}

public EmbedLinkThemeEnum getTheme() {
return theme;
}

public void setTheme(EmbedLinkThemeEnum theme) {
this.theme = theme;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cn.vika.client.api.model;

public class CreateEmbedLinkResponse {

private String linkId;

private String url;

private EmbedLinkPayload payload;

private EmbedLinkThemeEnum theme;

public String getLinkId() {
return linkId;
}

public void setLinkId(String linkId) {
this.linkId = linkId;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public EmbedLinkPayload getPayload() {
return payload;
}

public void setPayload(EmbedLinkPayload payload) {
this.payload = payload;
}

public EmbedLinkThemeEnum getTheme() {
return theme;
}

public void setTheme(EmbedLinkThemeEnum theme) {
this.theme = theme;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cn.vika.client.api.model;

public class EmbedLinkPayload {

private EmbedLinkPayloadSideBar primarySideBar;

private EmbedLinkPayloadViewControl viewControl;

private boolean bannerLogo;

private EmbedLinkPermissionEnum permissionType;

public EmbedLinkPayloadSideBar getPrimarySideBar() {
return primarySideBar;
}

public void setPrimarySideBar(EmbedLinkPayloadSideBar primarySideBar) {
this.primarySideBar = primarySideBar;
}

public EmbedLinkPayloadViewControl getViewControl() {
return viewControl;
}

public void setViewControl(EmbedLinkPayloadViewControl viewControl) {
this.viewControl = viewControl;
}

public boolean isBannerLogo() {
return bannerLogo;
}

public void setBannerLogo(boolean bannerLogo) {
this.bannerLogo = bannerLogo;
}

public EmbedLinkPermissionEnum getPermissionType() {
return permissionType;
}

public void setPermissionType(EmbedLinkPermissionEnum permissionType) {
this.permissionType = permissionType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cn.vika.client.api.model;

public class EmbedLinkPayloadSideBar {

private boolean collapsed;

public boolean isCollapsed() {
return collapsed;
}

public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cn.vika.client.api.model;

public class EmbedLinkPayloadViewControl {

private String viewId;

private boolean tabBar;

private EmbedLinkPayloadViewToolBar toolBar;

private boolean collapsed;

public String getViewId() {
return viewId;
}

public void setViewId(String viewId) {
this.viewId = viewId;
}

public boolean isTabBar() {
return tabBar;
}

public void setTabBar(boolean tabBar) {
this.tabBar = tabBar;
}

public EmbedLinkPayloadViewToolBar getToolBar() {
return toolBar;
}

public void setToolBar(EmbedLinkPayloadViewToolBar toolBar) {
this.toolBar = toolBar;
}

public boolean isCollapsed() {
return collapsed;
}

public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package cn.vika.client.api.model;

public class EmbedLinkPayloadViewToolBar {

private boolean basicTools;

private boolean shareBtn;

private boolean widgetBtn;

private boolean apiBtn;

private boolean formBtn;

private boolean historyBtn;

private boolean robotBtn;

public boolean isBasicTools() {
return basicTools;
}

public void setBasicTools(boolean basicTools) {
this.basicTools = basicTools;
}

public boolean isShareBtn() {
return shareBtn;
}

public void setShareBtn(boolean shareBtn) {
this.shareBtn = shareBtn;
}

public boolean isWidgetBtn() {
return widgetBtn;
}

public void setWidgetBtn(boolean widgetBtn) {
this.widgetBtn = widgetBtn;
}

public boolean isApiBtn() {
return apiBtn;
}

public void setApiBtn(boolean apiBtn) {
this.apiBtn = apiBtn;
}

public boolean isFormBtn() {
return formBtn;
}

public void setFormBtn(boolean formBtn) {
this.formBtn = formBtn;
}

public boolean isHistoryBtn() {
return historyBtn;
}

public void setHistoryBtn(boolean historyBtn) {
this.historyBtn = historyBtn;
}

public boolean isRobotBtn() {
return robotBtn;
}

public void setRobotBtn(boolean robotBtn) {
this.robotBtn = robotBtn;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cn.vika.client.api.model;

public enum EmbedLinkPermissionEnum {
readOnly,
publicEdit,
privateEdit;


// READ_ONLY("readOnly"),
//
// PUBLIC_EDIT("publicEdit"),
//
// PRIVATE_EDIT("privateEdit");
//
// private final String permissionType;
//
// EmbedLinkPermissionEnum(String permissionType){
// this.permissionType = permissionType;
// }
//
// public String getPermissionType(){
// return permissionType;
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be delete it.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cn.vika.client.api.model;

public enum EmbedLinkThemeEnum {
light,

dark;
}
Loading