Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added call that copies a chart from a workspace to another workspace #147

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions src/main/java/seatsio/charts/Charts.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ public Chart copyToWorkspace(String chartKey, String toWorkspaceKey) {
return gson().fromJson(response, Chart.class);
}

public Chart copyToWorkspace(String chartKey, String fromWorkspaceKey, String toWorkspaceKey) {
String response = unirest.stringResponse(UnirestWrapper.post(baseUrl + "/charts/{chartKey}/version/published/actions/copy/from/{fromWorkspaceKey}/to/{toWorkspaceKey}")
.routeParam("chartKey", chartKey)
.routeParam("fromWorkspaceKey", fromWorkspaceKey)
.routeParam("toWorkspaceKey", toWorkspaceKey));
return gson().fromJson(response, Chart.class);
}

public void addTag(String key, String tag) {
unirest.stringResponse(UnirestWrapper.post(baseUrl + "/charts/{key}/tags/{tag}")
.routeParam("key", key)
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/seatsio/charts/CopyChartFromWorkspaceToTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package seatsio.charts;

import org.junit.jupiter.api.Test;
import seatsio.SeatsioClient;
import seatsio.SeatsioClientTest;
import seatsio.workspaces.Workspace;

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

public class CopyChartFromWorkspaceToTest extends SeatsioClientTest {

@Test
public void test() {
Chart chart = client.charts.create("my chart", "BOOTHS");
Workspace toWorkspace = client.workspaces.create("my ws");

Chart copiedChart = client.charts.copyToWorkspace(chart.key, workspace.key, toWorkspace.key);

SeatsioClient workspaceClient = new SeatsioClient(toWorkspace.secretKey, null, apiUrl());
assertThat(copiedChart.name).isEqualTo("my chart");
Chart retrievedChart = workspaceClient.charts.retrieve(copiedChart.key);
assertThat(retrievedChart.name).isEqualTo("my chart");
Map<?, ?> drawing = workspaceClient.charts.retrievePublishedVersion(copiedChart.key);
assertThat(drawing.get("venueType")).isEqualTo("BOOTHS");
}

}